From b444c1ef555f6fb6752b0fd61ee3ef199ec190a0 Mon Sep 17 00:00:00 2001 From: Alex P Date: Mon, 17 Apr 2023 10:23:13 +0300 Subject: [PATCH] Fix block context --- modules/ppcp-button/src/Helper/ContextTrait.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/ppcp-button/src/Helper/ContextTrait.php b/modules/ppcp-button/src/Helper/ContextTrait.php index 2417464f6..7ce05ddbe 100644 --- a/modules/ppcp-button/src/Helper/ContextTrait.php +++ b/modules/ppcp-button/src/Helper/ContextTrait.php @@ -17,33 +17,32 @@ trait ContextTrait { * @return string */ protected function context(): string { - $context = 'mini-cart'; 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. if ( has_block( 'woocommerce/cart' ) ) { - $context = 'cart-block'; + return 'cart-block'; } if ( is_cart() ) { - $context = 'cart'; + return 'cart'; } if ( has_block( 'woocommerce/checkout' ) ) { - $context = 'checkout-block'; + return 'checkout-block'; } if ( ( is_checkout() ) && ! $this->is_paypal_continuation() ) { - $context = 'checkout'; + return 'checkout'; } if ( is_checkout_pay_page() ) { - $context = 'pay-now'; + return 'pay-now'; } - return $context; + return 'mini-cart'; } /**