diff --git a/modules/ppcp-button/src/Assets/SmartButton.php b/modules/ppcp-button/src/Assets/SmartButton.php index d5099aca1..d6b772fbf 100644 --- a/modules/ppcp-button/src/Assets/SmartButton.php +++ b/modules/ppcp-button/src/Assets/SmartButton.php @@ -234,7 +234,6 @@ class SmartButton implements SmartButtonInterface { if ( $this->settings->has( 'dcc_enabled' ) && $this->settings->get( 'dcc_enabled' ) - && ! $this->session_handler->order() ) { add_action( $this->checkout_dcc_button_renderer_hook(), @@ -1077,7 +1076,7 @@ class SmartButton implements SmartButtonInterface { if ( is_cart() ) { $context = 'cart'; } - if ( is_checkout() && ! $this->session_handler->order() ) { + if ( is_checkout() && ! $this->is_paypal_continuation() ) { $context = 'checkout'; } if ( is_checkout_pay_page() ) { @@ -1086,6 +1085,23 @@ class SmartButton implements SmartButtonInterface { return $context; } + /** + * Checks if PayPal payment was already initiated (on the product or cart pages). + * + * @return bool + */ + private function is_paypal_continuation(): bool { + $order = $this->session_handler->order(); + if ( ! $order ) { + return false; + } + $source = $order->payment_source(); + if ( $source && $source->card() ) { + return false; // Ignore for DCC. + } + return true; + } + /** * Whether DCC is enabled or not. * diff --git a/modules/ppcp-session/src/Cancellation/CancelController.php b/modules/ppcp-session/src/Cancellation/CancelController.php index 54eb13cb2..51d48008c 100644 --- a/modules/ppcp-session/src/Cancellation/CancelController.php +++ b/modules/ppcp-session/src/Cancellation/CancelController.php @@ -59,10 +59,17 @@ class CancelController { ) { // Input var ok. $this->session_handler->destroy_session_data(); } - if ( ! $this->session_handler->order() ) { + + $order = $this->session_handler->order(); + if ( ! $order ) { return; } + $source = $order->payment_source(); + if ( $source && $source->card() ) { + return; // Ignore for DCC. + } + $url = add_query_arg( array( $param_name => wp_create_nonce( $nonce ) ), wc_get_checkout_url() ); add_action( 'woocommerce_review_order_after_submit',