From 7c40f3b69ae61e0f3c4de352abf1a402e2d82178 Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Thu, 3 Sep 2020 21:09:05 +0700 Subject: [PATCH 1/2] Let action ppec_match_currency_order run after the other action in the main plugin More details in https://github.com/htdat/woo-viet/issues/73#issuecomment-685768769 --- inc/class-wooviet-vnd-paypal-express-checkout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/class-wooviet-vnd-paypal-express-checkout.php b/inc/class-wooviet-vnd-paypal-express-checkout.php index b73d894..ab4d511 100644 --- a/inc/class-wooviet-vnd-paypal-express-checkout.php +++ b/inc/class-wooviet-vnd-paypal-express-checkout.php @@ -49,7 +49,7 @@ class WooViet_VND_PayPal_Express_Checkout { add_action( 'woocommerce_paypal_express_checkout_valid_ipn_request', array( $this, 'ppec_match_currency_order' - ) ); + ), 20 ); // Add exchange rate before send request to PayPal add_filter( 'woocommerce_paypal_express_checkout_request_body', array( $this, 'ppec_convert_prices' ) ); From 05ae206a4eefb779d9c6f631a6918cbc58a26eee Mon Sep 17 00:00:00 2001 From: Dat Hoang Date: Thu, 3 Sep 2020 21:13:06 +0700 Subject: [PATCH 2/2] Ensure that PayPal Checkout SDK will load with the correct currency Details in this comment https://github.com/htdat/woo-viet/issues/73#issuecomment-685841637 --- inc/class-wooviet-vnd-paypal-express-checkout.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/inc/class-wooviet-vnd-paypal-express-checkout.php b/inc/class-wooviet-vnd-paypal-express-checkout.php index ab4d511..bc5b80d 100644 --- a/inc/class-wooviet-vnd-paypal-express-checkout.php +++ b/inc/class-wooviet-vnd-paypal-express-checkout.php @@ -54,6 +54,15 @@ class WooViet_VND_PayPal_Express_Checkout { // Add exchange rate before send request to PayPal add_filter( 'woocommerce_paypal_express_checkout_request_body', array( $this, 'ppec_convert_prices' ) ); + /** + * Ensure that PayPal Checkout SDK will load with the correct currency + * @see https://github.com/woocommerce/woocommerce-gateway-paypal-express-checkout/blob/f1f16de178cbf1d529deeaf574a52aca82a6e093/includes/class-wc-gateway-ppec-cart-handler.php#L553-L556 + */ + add_filter ('woocommerce_paypal_express_checkout_sdk_script_args', function( $script_args ) { + $script_args[ 'currency' ] = $this->ppec_currency; + return $script_args; + }); + // Load the method to add the exchange rate info for this gateway $this->ppec_exchange_rate_info();