mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Fix context() for checkout ajax refreshes
This commit is contained in:
parent
874a4e92ff
commit
9abaebf7db
1 changed files with 23 additions and 2 deletions
|
@ -12,6 +12,27 @@ namespace WooCommerce\PayPalCommerce\Button\Helper;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||||
|
|
||||||
trait ContextTrait {
|
trait ContextTrait {
|
||||||
|
/**
|
||||||
|
* Checks WC is_checkout() + WC checkout ajax requests.
|
||||||
|
*/
|
||||||
|
private function is_checkout(): bool {
|
||||||
|
if ( is_checkout() ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter returning whether to detect WC checkout ajax requests.
|
||||||
|
*/
|
||||||
|
if ( apply_filters( 'ppcp_check_ajax_checkout', true ) ) {
|
||||||
|
// phpcs:ignore WordPress.Security
|
||||||
|
$wc_ajax = $_GET['wc-ajax'] ?? '';
|
||||||
|
if ( in_array( $wc_ajax, array( 'update_order_review' ), true ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current context.
|
* The current context.
|
||||||
|
@ -23,7 +44,7 @@ trait ContextTrait {
|
||||||
|
|
||||||
// Do this check here instead of reordering outside conditions.
|
// Do this check here instead of reordering outside conditions.
|
||||||
// In order to have more control over the context.
|
// In order to have more control over the context.
|
||||||
if ( ( is_checkout() ) && ! $this->is_paypal_continuation() ) {
|
if ( $this->is_checkout() && ! $this->is_paypal_continuation() ) {
|
||||||
return 'checkout';
|
return 'checkout';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +68,7 @@ trait ContextTrait {
|
||||||
return 'checkout-block';
|
return 'checkout-block';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( is_checkout() ) && ! $this->is_paypal_continuation() ) {
|
if ( $this->is_checkout() && ! $this->is_paypal_continuation() ) {
|
||||||
return 'checkout';
|
return 'checkout';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue