From 4c33f0bee3a99a4eafb841482c25172a55388046 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 28 Jun 2023 11:22:11 +0100 Subject: [PATCH 1/2] Add woocommerce-one-page-checkout detection in product page --- modules/ppcp-button/src/Helper/ContextTrait.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/ppcp-button/src/Helper/ContextTrait.php b/modules/ppcp-button/src/Helper/ContextTrait.php index daddbb0a9..55169dac8 100644 --- a/modules/ppcp-button/src/Helper/ContextTrait.php +++ b/modules/ppcp-button/src/Helper/ContextTrait.php @@ -18,6 +18,12 @@ trait ContextTrait { */ protected function context(): string { if ( is_product() || wc_post_content_has_shortcode( 'product_page' ) ) { + + // Detection if "woocommerce-one-page-checkout" is enabled for this product. + if ( is_callable( 'is_wcopc_checkout' ) && is_wcopc_checkout( get_the_ID() ) ) { + return 'checkout'; + } + return 'product'; } From f517ac4719cbb2a1f5088d6db69afedbd0a66813 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 28 Jun 2023 15:15:49 +0100 Subject: [PATCH 2/2] Add checkout detection in product page --- modules/ppcp-button/src/Helper/ContextTrait.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-button/src/Helper/ContextTrait.php b/modules/ppcp-button/src/Helper/ContextTrait.php index 55169dac8..e1af3e3c0 100644 --- a/modules/ppcp-button/src/Helper/ContextTrait.php +++ b/modules/ppcp-button/src/Helper/ContextTrait.php @@ -19,8 +19,9 @@ trait ContextTrait { protected function context(): string { if ( is_product() || wc_post_content_has_shortcode( 'product_page' ) ) { - // Detection if "woocommerce-one-page-checkout" is enabled for this product. - if ( is_callable( 'is_wcopc_checkout' ) && is_wcopc_checkout( get_the_ID() ) ) { + // Do this check here instead of reordering outside conditions. + // In order to have more control over the context. + if ( ( is_checkout() ) && ! $this->is_paypal_continuation() ) { return 'checkout'; }