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
This commit is contained in:
Dwindi Ramadhana
2025-12-30 20:33:15 +07:00
parent f054a78c5d
commit fe98e6233d
5 changed files with 45 additions and 131 deletions

View File

@@ -89,12 +89,7 @@ class AppearanceController {
$general_data = [
'spa_mode' => sanitize_text_field($request->get_param('spaMode')),
'spa_pages' => [
'shop' => absint($request->get_param('spaPages')['shop'] ?? 0),
'cart' => absint($request->get_param('spaPages')['cart'] ?? 0),
'checkout' => absint($request->get_param('spaPages')['checkout'] ?? 0),
'account' => absint($request->get_param('spaPages')['account'] ?? 0),
],
'spa_page' => absint($request->get_param('spaPage') ?? 0),
'toast_position' => sanitize_text_field($request->get_param('toastPosition') ?? 'top-right'),
'typography' => [
'mode' => sanitize_text_field($request->get_param('typography')['mode'] ?? 'predefined'),
@@ -415,12 +410,7 @@ class AppearanceController {
return [
'general' => [
'spa_mode' => 'full',
'spa_pages' => [
'shop' => 0,
'cart' => 0,
'checkout' => 0,
'account' => 0,
],
'spa_page' => 0,
'toast_position' => 'top-right',
'typography' => [
'mode' => 'predefined',