fix: SPA disabled mode now renders WooCommerce templates properly

- Updated should_use_spa() to check correct setting (woonoow_appearance_settings['general']['spa_mode'])
- Updated is_spa_page() to also check spa_mode
- Updated should_remove_theme_elements() to use appearance settings
- When spa_mode = 'disabled', WooCommerce templates render normally
This commit is contained in:
Dwindi Ramadhana
2026-01-04 10:57:14 +07:00
parent 670bd7d351
commit 7c15850c8f

View File

@@ -417,19 +417,16 @@ class TemplateOverride
*/
private static function should_use_spa()
{
// Check if frontend mode is enabled
$mode = get_option('woonoow_frontend_mode', 'shortcodes');
// Check spa_mode from appearance settings
$appearance_settings = get_option('woonoow_appearance_settings', []);
$spa_mode = $appearance_settings['general']['spa_mode'] ?? 'full';
if ($mode === 'disabled') {
// Only use SPA when mode is 'full'
if ($spa_mode !== 'full') {
return false;
}
// For full SPA mode, always use SPA
if ($mode === 'full_spa') {
return true;
}
// For shortcode mode, check if we're on WooCommerce pages
// For full SPA mode, use SPA on WooCommerce pages
if (is_shop() || is_product() || is_cart() || is_checkout() || is_account_page()) {
return true;
}
@@ -475,12 +472,13 @@ class TemplateOverride
return false;
}
// Get SPA page ID from appearance settings
// Get SPA settings from appearance
$appearance_settings = get_option('woonoow_appearance_settings', []);
$spa_page_id = isset($appearance_settings['general']['spa_page']) ? $appearance_settings['general']['spa_page'] : 0;
$spa_page_id = $appearance_settings['general']['spa_page'] ?? 0;
$spa_mode = $appearance_settings['general']['spa_mode'] ?? 'full';
// Check if current page matches the SPA page
if ($spa_page_id && $post->ID == $spa_page_id) {
// Only return true if spa_mode is 'full' AND we're on the SPA page
if ($spa_mode === 'full' && $spa_page_id && $post->ID == $spa_page_id) {
return true;
}
@@ -497,38 +495,20 @@ class TemplateOverride
return true;
}
$settings = get_option('woonoow_customer_spa_settings', []);
$mode = isset($settings['mode']) ? $settings['mode'] : 'disabled';
// Check spa_mode from appearance settings
$appearance_settings = get_option('woonoow_appearance_settings', []);
$spa_mode = $appearance_settings['general']['spa_mode'] ?? 'full';
// Check if we're on a WooCommerce page in full mode
if ($mode === 'full') {
if ($spa_mode === 'full') {
if (is_shop() || is_product() || is_cart() || is_checkout() || is_account_page() || is_woocommerce()) {
return true;
}
}
// Also remove for pages with shortcodes (even in disabled mode)
global $post;
if (
$post && (
has_shortcode($post->post_content, 'woonoow_shop') ||
has_shortcode($post->post_content, 'woonoow_cart') ||
has_shortcode($post->post_content, 'woonoow_checkout') ||
has_shortcode($post->post_content, 'woonoow_account')
)
) {
return true;
}
// Special check for Shop page (archive)
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')) {
return true;
}
}
// When SPA is disabled, don't remove theme elements
if ($spa_mode === 'disabled') {
return false;
}
return false;