From 4c33f0bee3a99a4eafb841482c25172a55388046 Mon Sep 17 00:00:00 2001
From: Pedro Silva
Date: Wed, 28 Jun 2023 11:22:11 +0100
Subject: [PATCH] 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';
}