Merge pull request #1807 from woocommerce/PCP-2173-fix-cart-paylater

Pay Later messaging disappears when updating shipping option on cart page
This commit is contained in:
Emili Castells 2023-11-03 10:51:22 +01:00 committed by GitHub
commit c051e8ddc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,6 +34,28 @@ trait ContextTrait {
return false;
}
/**
* Checks WC is_cart() + WC cart ajax requests.
*/
private function is_cart(): bool {
if ( is_cart() ) {
return true;
}
/**
* The filter returning whether to detect WC cart ajax requests.
*/
if ( apply_filters( 'ppcp_check_ajax_cart', true ) ) {
// phpcs:ignore WordPress.Security
$wc_ajax = $_GET['wc-ajax'] ?? '';
if ( in_array( $wc_ajax, array( 'update_shipping_method' ), true ) ) {
return true;
}
}
return false;
}
/**
* The current context.
*
@ -56,7 +78,7 @@ trait ContextTrait {
return 'cart-block';
}
if ( is_cart() ) {
if ( $this->is_cart() ) {
return 'cart';
}