mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-09 21:57:02 +08:00
Merge pull request #933 from woocommerce/PCP-954-compatibility-with-wc-high-performance-order-storage
Compatibility with WC High-Performance Order Storage
This commit is contained in:
commit
933cede8d6
7 changed files with 32 additions and 8 deletions
|
@ -171,7 +171,11 @@ class OrderTrackingEndpoint {
|
||||||
throw $error;
|
throw $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_post_meta( $order_id, '_ppcp_paypal_tracking_number', $data['tracking_number'] ?? '' );
|
$wc_order = wc_get_order( $order_id );
|
||||||
|
if ( is_a( $wc_order, WC_Order::class ) ) {
|
||||||
|
$wc_order->update_meta_data( '_ppcp_paypal_tracking_number', $data['tracking_number'] ?? '' );
|
||||||
|
$wc_order->save();
|
||||||
|
}
|
||||||
|
|
||||||
do_action( 'woocommerce_paypal_payments_after_tracking_is_added', $order_id, $response );
|
do_action( 'woocommerce_paypal_payments_after_tracking_is_added', $order_id, $response );
|
||||||
}
|
}
|
||||||
|
@ -300,7 +304,11 @@ class OrderTrackingEndpoint {
|
||||||
throw $error;
|
throw $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_post_meta( $order_id, '_ppcp_paypal_tracking_number', $data['tracking_number'] ?? '' );
|
$wc_order = wc_get_order( $order_id );
|
||||||
|
if ( is_a( $wc_order, WC_Order::class ) ) {
|
||||||
|
$wc_order->update_meta_data( '_ppcp_paypal_tracking_number', $data['tracking_number'] ?? '' );
|
||||||
|
$wc_order->save();
|
||||||
|
}
|
||||||
|
|
||||||
do_action( 'woocommerce_paypal_payments_after_tracking_is_updated', $order_id, $response );
|
do_action( 'woocommerce_paypal_payments_after_tracking_is_updated', $order_id, $response );
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,9 +175,9 @@ class SubscriptionModule implements ModuleInterface {
|
||||||
try {
|
try {
|
||||||
$tokens = $payment_token_repository->all_for_user_id( $subscription->get_customer_id() );
|
$tokens = $payment_token_repository->all_for_user_id( $subscription->get_customer_id() );
|
||||||
if ( $tokens ) {
|
if ( $tokens ) {
|
||||||
$subscription_id = $subscription->get_id();
|
|
||||||
$latest_token_id = end( $tokens )->id() ? end( $tokens )->id() : '';
|
$latest_token_id = end( $tokens )->id() ? end( $tokens )->id() : '';
|
||||||
update_post_meta( $subscription_id, 'payment_token_id', $latest_token_id, true );
|
$subscription->update_meta_data( 'payment_token_id', $latest_token_id );
|
||||||
|
$subscription->save();
|
||||||
}
|
}
|
||||||
} catch ( RuntimeException $error ) {
|
} catch ( RuntimeException $error ) {
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
|
|
|
@ -151,7 +151,9 @@ class VaultedCreditCardHandler {
|
||||||
&& $this->subscription_helper->is_subscription_change_payment()
|
&& $this->subscription_helper->is_subscription_change_payment()
|
||||||
&& $saved_credit_card
|
&& $saved_credit_card
|
||||||
) {
|
) {
|
||||||
update_post_meta( $wc_order->get_id(), 'payment_token_id', $saved_credit_card );
|
$wc_order->update_meta_data( 'payment_token_id', $saved_credit_card );
|
||||||
|
$wc_order->save();
|
||||||
|
|
||||||
return $wc_order;
|
return $wc_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,8 @@ class CardButtonGateway extends \WC_Payment_Gateway {
|
||||||
if ( $this->subscription_helper->has_subscription( $order_id ) && $this->subscription_helper->is_subscription_change_payment() ) {
|
if ( $this->subscription_helper->has_subscription( $order_id ) && $this->subscription_helper->is_subscription_change_payment() ) {
|
||||||
$saved_paypal_payment = filter_input( INPUT_POST, 'saved_paypal_payment', FILTER_SANITIZE_STRING );
|
$saved_paypal_payment = filter_input( INPUT_POST, 'saved_paypal_payment', FILTER_SANITIZE_STRING );
|
||||||
if ( $saved_paypal_payment ) {
|
if ( $saved_paypal_payment ) {
|
||||||
update_post_meta( $order_id, 'payment_token_id', $saved_paypal_payment );
|
$wc_order->update_meta_data( 'payment_token_id', $saved_paypal_payment );
|
||||||
|
$wc_order->save();
|
||||||
|
|
||||||
return $this->handle_payment_success( $wc_order );
|
return $this->handle_payment_success( $wc_order );
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,8 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
||||||
if ( $this->subscription_helper->has_subscription( $order_id ) && $this->subscription_helper->is_subscription_change_payment() ) {
|
if ( $this->subscription_helper->has_subscription( $order_id ) && $this->subscription_helper->is_subscription_change_payment() ) {
|
||||||
$saved_paypal_payment = filter_input( INPUT_POST, 'saved_paypal_payment', FILTER_SANITIZE_STRING );
|
$saved_paypal_payment = filter_input( INPUT_POST, 'saved_paypal_payment', FILTER_SANITIZE_STRING );
|
||||||
if ( $saved_paypal_payment ) {
|
if ( $saved_paypal_payment ) {
|
||||||
update_post_meta( $order_id, 'payment_token_id', $saved_paypal_payment );
|
$wc_order->update_meta_data( 'payment_token_id', $saved_paypal_payment );
|
||||||
|
$wc_order->save();
|
||||||
|
|
||||||
return $this->handle_payment_success( $wc_order );
|
return $this->handle_payment_success( $wc_order );
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,12 @@ class VaultedCreditCardHandlerTest extends TestCase
|
||||||
when('filter_input')->justReturn(1);
|
when('filter_input')->justReturn(1);
|
||||||
$wcOrder = Mockery::mock(\WC_Order::class);
|
$wcOrder = Mockery::mock(\WC_Order::class);
|
||||||
$wcOrder->shouldReceive('get_id')->andReturn(1);
|
$wcOrder->shouldReceive('get_id')->andReturn(1);
|
||||||
|
$wcOrder->shouldReceive('update_meta_data')
|
||||||
|
->with('payment_token_id', 'abc123')
|
||||||
|
->andReturn(1);
|
||||||
|
$wcOrder->shouldReceive('save')->andReturn(1);
|
||||||
$this->subscriptionHelper->shouldReceive('has_subscription')->andReturn(true);
|
$this->subscriptionHelper->shouldReceive('has_subscription')->andReturn(true);
|
||||||
$this->subscriptionHelper->shouldReceive('is_subscription_change_payment')->andReturn(true);
|
$this->subscriptionHelper->shouldReceive('is_subscription_change_payment')->andReturn(true);
|
||||||
expect('update_post_meta')->with(1, 'payment_token_id', 'abc123');
|
|
||||||
|
|
||||||
$customer = Mockery::mock(WC_Customer::class);
|
$customer = Mockery::mock(WC_Customer::class);
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,15 @@ define( 'PPCP_FLAG_SEPARATE_APM_BUTTONS', apply_filters( 'woocommerce_paypal_pay
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
add_action(
|
||||||
|
'before_woocommerce_init',
|
||||||
|
function() {
|
||||||
|
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
|
||||||
|
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if WooCommerce is active.
|
* Check if WooCommerce is active.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue