feat: Add-to-cart from URL parameters
Implements direct-to-cart functionality for landing page CTAs. Features: - Parse URL parameters: ?add-to-cart=123 - Support simple products: ?add-to-cart=123 - Support variable products: ?add-to-cart=123&variation_id=456 - Support quantity: ?add-to-cart=123&quantity=2 - Auto-navigate to cart after adding - Clean URL after adding (remove parameters) - Toast notification on success/error Usage examples: 1. Simple product: https://site.com/store?add-to-cart=332 2. Variable product: https://site.com/store?add-to-cart=332&variation_id=456 3. With quantity: https://site.com/store?add-to-cart=332&quantity=3 Flow: - User clicks CTA on landing page - Redirects to SPA with add-to-cart parameter - SPA loads, hook detects parameter - Adds product to cart via API - Navigates to cart page - Shows success toast Works with both SPA modes: - Full SPA: loads shop, adds to cart, navigates to cart - Checkout Only: loads cart, adds to cart, stays on cart
This commit is contained in:
@@ -12,15 +12,21 @@
|
||||
$appearance_settings = get_option('woonoow_appearance_settings', []);
|
||||
$spa_mode = isset($appearance_settings['general']['spa_mode']) ? $appearance_settings['general']['spa_mode'] : 'full';
|
||||
|
||||
// Debug logging
|
||||
error_log('[WooNooW SPA Template] Settings: ' . print_r($appearance_settings, true));
|
||||
error_log('[WooNooW SPA Template] SPA Mode: ' . $spa_mode);
|
||||
|
||||
// Set initial page based on mode
|
||||
if ($spa_mode === 'checkout_only') {
|
||||
// Checkout Only mode starts at cart
|
||||
$page_type = 'cart';
|
||||
$data_attrs = 'data-page="cart" data-initial-route="/cart"';
|
||||
error_log('[WooNooW SPA Template] Using CART initial route');
|
||||
} else {
|
||||
// Full SPA mode starts at shop
|
||||
$page_type = 'shop';
|
||||
$data_attrs = 'data-page="shop" data-initial-route="/shop"';
|
||||
error_log('[WooNooW SPA Template] Using SHOP initial route');
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user