Simplify: Remove meta from resubscribe orders
In Subscriptoins v2.0. Also deprecate the removal of it in 1.n, where resubscribe orders were called "parent renewal orders".
This commit is contained in:
parent
089485b3bf
commit
73999c5daf
|
@ -24,6 +24,7 @@ class WC_Addons_Gateway_Simplify_Commerce_Deprecated extends WC_Addons_Gateway_S
|
||||||
|
|
||||||
if ( class_exists( 'WC_Subscriptions_Order' ) ) {
|
if ( class_exists( 'WC_Subscriptions_Order' ) ) {
|
||||||
add_action( 'scheduled_subscription_payment_' . $this->id, array( $this, 'process_scheduled_subscription_payment' ), 10, 3 );
|
add_action( 'scheduled_subscription_payment_' . $this->id, array( $this, 'process_scheduled_subscription_payment' ), 10, 3 );
|
||||||
|
add_filter( 'woocommerce_subscriptions_renewal_order_meta_query', array( $this, 'remove_renewal_order_meta' ), 10, 4 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,4 +132,21 @@ class WC_Addons_Gateway_Simplify_Commerce_Deprecated extends WC_Addons_Gateway_S
|
||||||
WC_Subscriptions_Manager::process_subscription_payments_on_order( $order );
|
WC_Subscriptions_Manager::process_subscription_payments_on_order( $order );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't transfer customer meta when creating a parent renewal order.
|
||||||
|
*
|
||||||
|
* @param string $order_meta_query MySQL query for pulling the metadata
|
||||||
|
* @param int $original_order_id Post ID of the order being used to purchased the subscription being renewed
|
||||||
|
* @param int $renewal_order_id Post ID of the order created for renewing the subscription
|
||||||
|
* @param string $new_order_role The role the renewal order is taking, one of 'parent' or 'child'
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function remove_renewal_order_meta( $order_meta_query, $original_order_id, $renewal_order_id, $new_order_role ) {
|
||||||
|
if ( 'parent' == $new_order_role ) {
|
||||||
|
$order_meta_query .= " AND `meta_key` NOT LIKE '_simplify_customer_id' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $order_meta_query;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,10 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
|
||||||
|
|
||||||
if ( class_exists( 'WC_Subscriptions_Order' ) ) {
|
if ( class_exists( 'WC_Subscriptions_Order' ) ) {
|
||||||
add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
|
add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
|
||||||
add_filter( 'woocommerce_subscriptions_renewal_order_meta_query', array( $this, 'remove_renewal_order_meta' ), 10, 4 );
|
|
||||||
add_action( 'woocommerce_subscriptions_changed_failing_payment_method_' . $this->id, array( $this, 'update_failing_payment_method' ), 10, 3 );
|
add_action( 'woocommerce_subscriptions_changed_failing_payment_method_' . $this->id, array( $this, 'update_failing_payment_method' ), 10, 3 );
|
||||||
|
|
||||||
|
add_action( 'wcs_resubscribe_order_created', array( $this, 'delete_resubscribe_meta' ), 10 );
|
||||||
|
|
||||||
// Allow store managers to manually set Simplify as the payment method on a subscription
|
// Allow store managers to manually set Simplify as the payment method on a subscription
|
||||||
add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 );
|
add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 );
|
||||||
add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
|
add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 );
|
||||||
|
@ -357,23 +358,6 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Don't transfer customer meta when creating a parent renewal order.
|
|
||||||
*
|
|
||||||
* @param string $order_meta_query MySQL query for pulling the metadata
|
|
||||||
* @param int $original_order_id Post ID of the order being used to purchased the subscription being renewed
|
|
||||||
* @param int $renewal_order_id Post ID of the order created for renewing the subscription
|
|
||||||
* @param string $new_order_role The role the renewal order is taking, one of 'parent' or 'child'
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function remove_renewal_order_meta( $order_meta_query, $original_order_id, $renewal_order_id, $new_order_role ) {
|
|
||||||
if ( 'parent' == $new_order_role ) {
|
|
||||||
$order_meta_query .= " AND `meta_key` NOT LIKE '_simplify_customer_id' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $order_meta_query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the customer_id for a subscription after using Simplify to complete a payment to make up for
|
* Update the customer_id for a subscription after using Simplify to complete a payment to make up for
|
||||||
* an automatic renewal payment which previously failed.
|
* an automatic renewal payment which previously failed.
|
||||||
|
@ -428,6 +412,17 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't transfer customer meta to resubscribe orders.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function delete_resubscribe_meta( $resubscribe_order ) {
|
||||||
|
delete_post_meta( $resubscribe_order->id, '_simplify_customer_id' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a pre-order payment when the pre-order is released
|
* Process a pre-order payment when the pre-order is released
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue