Add woocommerce-one-page-checkout detection in product page

This commit is contained in:
Pedro Silva 2023-06-28 11:22:11 +01:00
parent b4cc4dcfe9
commit 4c33f0bee3
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3

View file

@ -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';
}