From b2ac2996f9e970e07538cee5a96341614f25ab0b Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Tue, 30 Dec 2025 18:02:48 +0700 Subject: [PATCH] fix: Detect shortcode on WooCommerce Shop page correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Customer SPA not loading on Shop page despite having [woonoow_shop] shortcode Root Cause: WooCommerce Shop page is an archive page - when visiting /shop/, WordPress sets $post to the first product in the loop, not the Shop page itself. So shortcode check was checking product content instead of Shop page content. Solution: Add special handling for is_shop() - get Shop page content directly using woocommerce_shop_page_id option and check for shortcode there. Changes: - Check is_shop() first before checking $post content - Get Shop page via get_option('woocommerce_shop_page_id') - Check shortcode on actual Shop page content - Falls back to regular $post check for other pages Result: ✅ Shop page shortcode detection now works correctly ✅ Customer SPA will load on Shop page with [woonoow_shop] shortcode ✅ Other WooCommerce pages (Cart, Checkout, Account) still work --- includes/Frontend/Assets.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/Frontend/Assets.php b/includes/Frontend/Assets.php index 4ed9ee2..232613d 100644 --- a/includes/Frontend/Assets.php +++ b/includes/Frontend/Assets.php @@ -262,7 +262,19 @@ class Assets { // If disabled, don't load if ($mode === 'disabled') { - // Still check for shortcodes + // Special handling for WooCommerce Shop page (it's an archive, not a regular post) + if (function_exists('is_shop') && is_shop()) { + $shop_page_id = get_option('woocommerce_shop_page_id'); + if ($shop_page_id) { + $shop_page = get_post($shop_page_id); + if ($shop_page && has_shortcode($shop_page->post_content, 'woonoow_shop')) { + error_log('[WooNooW Customer] Found woonoow_shop shortcode on Shop page (ID: ' . $shop_page_id . ')'); + return true; + } + } + } + + // Check for shortcodes on regular pages if ($post) { error_log('[WooNooW Customer] Checking post content for shortcodes'); error_log('[WooNooW Customer] Post content: ' . substr($post->post_content, 0, 200));