'disabled',
'layout' => 'modern',
'colors' => [
'primary' => '#3B82F6',
'secondary' => '#8B5CF6',
'accent' => '#10B981',
],
'typography' => [
'preset' => 'professional',
],
];
$theme_settings = array_replace_recursive($default_settings, $spa_settings);
// Get WooCommerce currency settings
$currency_settings = [
'code' => get_woocommerce_currency(),
'symbol' => get_woocommerce_currency_symbol(),
'position' => get_option('woocommerce_currency_pos', 'left'),
'thousandSeparator' => wc_get_price_thousand_separator(),
'decimalSeparator' => wc_get_price_decimal_separator(),
'decimals' => wc_get_price_decimals(),
];
$config = [
'apiUrl' => rest_url('woonoow/v1'),
'nonce' => wp_create_nonce('wp_rest'),
'siteUrl' => get_site_url(),
'siteTitle' => get_bloginfo('name'),
'user' => [
'isLoggedIn' => is_user_logged_in(),
'id' => get_current_user_id(),
],
'theme' => $theme_settings,
'currency' => $currency_settings,
];
?>
post_content, 'woonoow_shop')) {
return true;
}
if ($post && has_shortcode($post->post_content, 'woonoow_cart')) {
return true;
}
if ($post && has_shortcode($post->post_content, 'woonoow_checkout')) {
return true;
}
return false;
}
// Full SPA mode - load on all WooCommerce pages
if ($mode === 'full') {
if (function_exists('is_shop') && is_shop()) {
return true;
}
if (function_exists('is_product') && is_product()) {
return true;
}
if (function_exists('is_cart') && is_cart()) {
return true;
}
if (function_exists('is_checkout') && is_checkout()) {
return true;
}
if (function_exists('is_account_page') && is_account_page()) {
return true;
}
return false;
}
// Checkout-Only mode - load only on specific pages
if ($mode === 'checkout_only') {
$checkout_pages = isset($spa_settings['checkoutPages']) ? $spa_settings['checkoutPages'] : [];
if (!empty($checkout_pages['checkout']) && function_exists('is_checkout') && is_checkout() && !is_order_received_page()) {
return true;
}
if (!empty($checkout_pages['thankyou']) && function_exists('is_order_received_page') && is_order_received_page()) {
return true;
}
if (!empty($checkout_pages['account']) && function_exists('is_account_page') && is_account_page()) {
return true;
}
if (!empty($checkout_pages['cart']) && function_exists('is_cart') && is_cart()) {
return true;
}
return false;
}
// Check if current page has WooNooW shortcodes
if ($post && has_shortcode($post->post_content, 'woonoow_shop')) {
return true;
}
if ($post && has_shortcode($post->post_content, 'woonoow_cart')) {
return true;
}
if ($post && has_shortcode($post->post_content, 'woonoow_checkout')) {
return true;
}
if ($post && has_shortcode($post->post_content, 'woonoow_account')) {
return true;
}
return false;
}
/**
* Dequeue conflicting scripts when SPA is active
*/
public static function dequeue_conflicting_scripts() {
if (!self::should_load_assets()) {
return;
}
// Dequeue WooCommerce scripts that conflict with SPA
wp_dequeue_script('wc-cart-fragments');
wp_dequeue_script('woocommerce');
wp_dequeue_script('wc-add-to-cart');
wp_dequeue_script('wc-add-to-cart-variation');
// Dequeue WordPress block scripts that cause errors in SPA
wp_dequeue_script('wp-block-library');
wp_dequeue_script('wp-block-navigation');
wp_dequeue_script('wp-interactivity');
wp_dequeue_script('wp-interactivity-router');
// Keep only essential WooCommerce styles, dequeue others if needed
// wp_dequeue_style('woocommerce-general');
// wp_dequeue_style('woocommerce-layout');
// wp_dequeue_style('woocommerce-smallscreen');
}
}