mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #1363 from woocommerce/PCP-1544-pay-order-currency
Use order currency instead of shop currency on order-pay page
This commit is contained in:
commit
ad30fea667
1 changed files with 30 additions and 3 deletions
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\Button\Assets;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use WC_Order;
|
||||||
use WC_Product;
|
use WC_Product;
|
||||||
use WC_Product_Variation;
|
use WC_Product_Variation;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
||||||
|
@ -796,8 +797,6 @@ class SmartButton implements SmartButtonInterface {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function script_data(): array {
|
public function script_data(): array {
|
||||||
global $wp;
|
|
||||||
|
|
||||||
$is_free_trial_cart = $this->is_free_trial_cart();
|
$is_free_trial_cart = $this->is_free_trial_cart();
|
||||||
|
|
||||||
$url_params = $this->url_params();
|
$url_params = $this->url_params();
|
||||||
|
@ -938,7 +937,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
// phpcs:ignore WordPress.WP.I18n
|
// phpcs:ignore WordPress.WP.I18n
|
||||||
'shipping_field' => _x( 'Shipping %s', 'checkout-validation', 'woocommerce' ),
|
'shipping_field' => _x( 'Shipping %s', 'checkout-validation', 'woocommerce' ),
|
||||||
),
|
),
|
||||||
'order_id' => 'pay-now' === $this->context() ? absint( $wp->query_vars['order-pay'] ) : 0,
|
'order_id' => 'pay-now' === $this->context() ? $this->get_order_pay_id() : 0,
|
||||||
'single_product_buttons_enabled' => $this->settings_status->is_smart_button_enabled_for_location( 'product' ),
|
'single_product_buttons_enabled' => $this->settings_status->is_smart_button_enabled_for_location( 'product' ),
|
||||||
'mini_cart_buttons_enabled' => $this->settings_status->is_smart_button_enabled_for_location( 'mini-cart' ),
|
'mini_cart_buttons_enabled' => $this->settings_status->is_smart_button_enabled_for_location( 'mini-cart' ),
|
||||||
'basic_checkout_validation_enabled' => $this->basic_checkout_validation_enabled,
|
'basic_checkout_validation_enabled' => $this->basic_checkout_validation_enabled,
|
||||||
|
@ -1011,6 +1010,19 @@ class SmartButton implements SmartButtonInterface {
|
||||||
$params['buyer-country'] = WC()->customer->get_billing_country();
|
$params['buyer-country'] = WC()->customer->get_billing_country();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( 'pay-now' === $this->context() ) {
|
||||||
|
$wc_order_id = $this->get_order_pay_id();
|
||||||
|
if ( $wc_order_id ) {
|
||||||
|
$wc_order = wc_get_order( $wc_order_id );
|
||||||
|
if ( $wc_order instanceof WC_Order ) {
|
||||||
|
$currency = $wc_order->get_currency();
|
||||||
|
if ( $currency ) {
|
||||||
|
$params['currency'] = $currency;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$disable_funding = $this->settings->has( 'disable_funding' )
|
$disable_funding = $this->settings->has( 'disable_funding' )
|
||||||
? $this->settings->get( 'disable_funding' )
|
? $this->settings->get( 'disable_funding' )
|
||||||
: array();
|
: array();
|
||||||
|
@ -1437,4 +1449,19 @@ class SmartButton implements SmartButtonInterface {
|
||||||
|
|
||||||
return $this->context() === 'product' ? $product_intent : $other_context_intent;
|
return $this->context() === 'product' ? $product_intent : $other_context_intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ID of WC order on the order-pay page, or 0.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function get_order_pay_id(): int {
|
||||||
|
global $wp;
|
||||||
|
|
||||||
|
if ( ! isset( $wp->query_vars['order-pay'] ) ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return absint( $wp->query_vars['order-pay'] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue