This commit is contained in:
Prospress Inc
2017-06-09 16:36:26 +02:00
committed by Remco Tolsma
parent 5e536ec717
commit b99eba2f79
51 changed files with 1413 additions and 642 deletions

View File

@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
function wcs_order_contains_switch( $order ) {
if ( ! is_object( $order ) ) {
if ( ! is_a( $order, 'WC_Abstract_Order' ) ) {
$order = wc_get_order( $order );
}
@@ -30,9 +30,9 @@ function wcs_order_contains_switch( $order ) {
} else {
$subscription_ids = wcs_get_objects_property( $order, 'subscription_switch', 'multiple' );
$switched_subscriptions = wcs_get_subscriptions_for_switch_order( $order );
if ( ! empty( $subscription_ids ) ) {
if ( ! empty( $switched_subscriptions ) ) {
$is_switch_order = true;
} else {
$is_switch_order = false;
@@ -51,7 +51,7 @@ function wcs_order_contains_switch( $order ) {
*/
function wcs_get_subscriptions_for_switch_order( $order ) {
if ( ! is_object( $order ) ) {
if ( ! is_a( $order, 'WC_Abstract_Order' ) ) {
$order = wc_get_order( $order );
}
@@ -59,7 +59,12 @@ function wcs_get_subscriptions_for_switch_order( $order ) {
$subscription_ids = wcs_get_objects_property( $order, 'subscription_switch', 'multiple' );
foreach ( $subscription_ids as $subscription_id ) {
$subscriptions[ $subscription_id ] = wcs_get_subscription( $subscription_id );
$subscription = wcs_get_subscription( $subscription_id );
if ( $subscription ) {
$subscriptions[ $subscription_id ] = $subscription;
}
}
return $subscriptions;