mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Fix block context
This commit is contained in:
parent
19f004becd
commit
b444c1ef55
1 changed files with 7 additions and 8 deletions
|
@ -17,33 +17,32 @@ trait ContextTrait {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function context(): string {
|
protected function context(): string {
|
||||||
$context = 'mini-cart';
|
|
||||||
if ( is_product() || wc_post_content_has_shortcode( 'product_page' ) ) {
|
if ( is_product() || wc_post_content_has_shortcode( 'product_page' ) ) {
|
||||||
$context = 'product';
|
return 'product';
|
||||||
}
|
}
|
||||||
|
|
||||||
// has_block may not work if called too early, such as during the block registration.
|
// has_block may not work if called too early, such as during the block registration.
|
||||||
if ( has_block( 'woocommerce/cart' ) ) {
|
if ( has_block( 'woocommerce/cart' ) ) {
|
||||||
$context = 'cart-block';
|
return 'cart-block';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_cart() ) {
|
if ( is_cart() ) {
|
||||||
$context = 'cart';
|
return 'cart';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( has_block( 'woocommerce/checkout' ) ) {
|
if ( has_block( 'woocommerce/checkout' ) ) {
|
||||||
$context = 'checkout-block';
|
return 'checkout-block';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( is_checkout() ) && ! $this->is_paypal_continuation() ) {
|
if ( ( is_checkout() ) && ! $this->is_paypal_continuation() ) {
|
||||||
$context = 'checkout';
|
return 'checkout';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_checkout_pay_page() ) {
|
if ( is_checkout_pay_page() ) {
|
||||||
$context = 'pay-now';
|
return 'pay-now';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $context;
|
return 'mini-cart';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue