Files
WooNooW/templates/spa-full-page.php
Dwindi Ramadhana fe98e6233d refactor: Simplify to single SPA entry page architecture
User feedback: 'SPA means Single Page, why 4 pages?'

Correct architecture:
- 1 SPA entry page (e.g., /store)
- SPA Mode determines initial route:
  * Full SPA → starts at shop page
  * Checkout Only → starts at cart page
  * Disabled → never loads
- React Router handles rest via /#/ routing

Changes:
- Admin UI: Changed from 4 page selectors to 1 SPA entry page
- Backend: spa_pages array → spa_page integer
- Template: Initial route based on spa_mode setting
- Simplified is_spa_page() checks (single ID comparison)

Benefits:
- User can set /store as homepage (Settings → Reading)
- Landing page → CTA → direct to cart/checkout
- Clean single entry point
- Mode controls behavior, not multiple pages

Example flow:
- Visit https://site.com/store
- Full SPA: loads shop, navigate via /#/product/123
- Checkout Only: loads cart, navigate via /#/checkout
- Homepage: set /store as homepage, SPA loads on site root

Next: Add direct-to-cart CTA with product parameter
2025-12-30 20:33:15 +07:00

36 lines
1.3 KiB
PHP

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php wp_title('|', true, 'right'); ?><?php bloginfo('name'); ?></title>
<?php wp_head(); ?>
</head>
<body <?php body_class('woonoow-spa-page'); ?>>
<?php
// Determine initial route based on SPA mode
$appearance_settings = get_option('woonoow_appearance_settings', []);
$spa_mode = isset($appearance_settings['general']['spa_mode']) ? $appearance_settings['general']['spa_mode'] : 'full';
// 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"';
} else {
// Full SPA mode starts at shop
$page_type = 'shop';
$data_attrs = 'data-page="shop" data-initial-route="/shop"';
}
?>
<div id="woonoow-customer-app" <?php echo $data_attrs; ?>>
<div class="woonoow-loading" style="display: flex; align-items: center; justify-content: center; min-height: 100vh; font-family: system-ui, -apple-system, sans-serif;">
<p><?php esc_html_e('Loading...', 'woonoow'); ?></p>
</div>
</div>
<?php wp_footer(); ?>
</body>
</html>