Commit Graph

17 Commits

Author SHA1 Message Date
Dwindi Ramadhana
58681e272e feat: temp password in emails + WC page redirects to SPA
1. Temp password for auto-registered users:
   - Store password in _woonoow_temp_password user meta (CheckoutController)
   - Add {user_temp_password} and {login_url} variables (EmailRenderer)
   - Update new_customer email template to show credentials

2. WC page redirects to SPA routes:
   - Added redirect_wc_pages_to_spa() in TemplateOverride
   - Maps: /shop → /store/#/, /cart → /store/#/cart, etc.
   - /checkout → /store/#/checkout, /my-account → /store/#/account
   - Single products → /store/#/products/{slug}

3. Removed shortcode system:
   - Commented out Shortcodes::init() in Bootstrap
   - WC pages now redirect to SPA instead
2026-01-01 16:45:24 +07:00
Dwindi Ramadhana
82399d4ddf fix: WP-Admin CSS conflicts and add-to-cart redirect
- Fix CSS conflicts between WP-Admin and SPA (radio buttons, chart text)
- Add Tailwind important selector scoped to #woonoow-admin-app
- Remove overly aggressive inline SVG styles from Assets.php
- Add targeted WordPress admin CSS overrides in index.css
- Fix add-to-cart redirect to use woocommerce_add_to_cart_redirect filter
- Let WooCommerce handle cart operations natively for proper session management
- Remove duplicate tailwind.config.cjs
2025-12-31 14:06:04 +07:00
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
Dwindi Ramadhana
012effd11d feat: Add dedicated SPA page selection (WooCommerce-style)
Problem: Shortcode 'island' architecture is fragile and theme-dependent
- SPA div buried deep in theme structure (body > div.wp-site-blocks > main > div#app)
- Theme and plugins can intervene at any level
- Different themes have different structures
- Breaks easily with theme changes

Solution: Dedicated page-based SPA system (like WooCommerce)
- Add page selection in Appearance > General settings
- Store page IDs for Shop, Cart, Checkout, Account
- Full-body SPA rendering on designated pages
- No theme interference

Changes:
- AppearanceController.php:
  * Added spa_pages field to general settings
  * Stores page IDs for each SPA type (shop/cart/checkout/account)

- TemplateOverride.php:
  * Added is_spa_page() method to check designated pages
  * Use blank template for designated pages (priority over legacy)
  * Remove theme elements for designated pages

- Assets.php:
  * Added is_spa_page() check before mode/shortcode checks
  * Load assets on designated pages regardless of mode

Architecture:
- Designated pages render directly to <body>
- No theme wrapper/structure interference
- Clean full-page SPA experience
- Works with ANY theme consistently

Next: Add UI in admin-spa General tab for page selection
2025-12-30 19:42:16 +07:00
Dwindi Ramadhana
48a5a5593b fix: Include fonts in production build and strengthen theme override
Problem 1: Fonts not loading (404 errors)
Root Cause: Build script only copied app.js and app.css, not fonts folder
Solution: Include fonts directory in production build

Problem 2: Theme header/footer still showing on some themes
Root Cause: Header/footer removal only worked in 'full' mode, not for shortcode pages
Solution:
- Use blank template (spa-full-page.php) for ANY page with WooNooW shortcodes
- Remove theme elements for shortcode pages even in 'disabled' mode
- Stronger detection for Shop page (archive) shortcode check

Changes:
- build-production.sh: Copy fonts folder if exists
- TemplateOverride.php:
  * use_spa_template() now checks for shortcodes in disabled mode
  * should_remove_theme_elements() removes for shortcode pages
  * Added Shop page archive check for shortcode detection

Result:
 Fonts now included in production build (~500KB added)
 Theme header/footer removed on ALL shortcode pages
 Works with any theme (Astra, Twenty Twenty-Three, etc.)
 Clean SPA experience regardless of SPA mode setting
 Package size: 2.1M (was 1.6M, +500KB for fonts)
2025-12-30 19:34:39 +07:00
Dwindi Ramadhana
e0777c708b fix: Remove theme header and footer in Full SPA mode
Problem: Duplicate headers and footers showing (theme + SPA)
Root Cause: Theme's header and footer still rendering when Full SPA mode is active

Solution: Remove theme header/footer elements when on WooCommerce pages in Full SPA mode
- Hook into get_header and get_footer actions
- Remove all theme header/footer actions
- Keep only essential WordPress head/footer scripts
- Only applies when mode='full' and on WooCommerce pages

Changes:
- Added remove_theme_header() method
- Added remove_theme_footer() method
- Added should_remove_theme_elements() check
- Hooks into get_header and get_footer

Result:
 Clean SPA experience without theme header/footer
 Essential WordPress scripts still load
 Only affects Full SPA mode on WooCommerce pages
 Other pages keep theme header/footer
2025-12-30 18:10:29 +07:00
Dwindi Ramadhana
b2ac2996f9 fix: Detect shortcode on WooCommerce Shop page correctly
Problem: Customer SPA not loading on Shop page despite having [woonoow_shop] shortcode
Root Cause: WooCommerce Shop page is an archive page - when visiting /shop/, WordPress sets $post to the first product in the loop, not the Shop page itself. So shortcode check was checking product content instead of Shop page content.

Solution: Add special handling for is_shop() - get Shop page content directly using woocommerce_shop_page_id option and check for shortcode there.

Changes:
- Check is_shop() first before checking $post content
- Get Shop page via get_option('woocommerce_shop_page_id')
- Check shortcode on actual Shop page content
- Falls back to regular $post check for other pages

Result:
 Shop page shortcode detection now works correctly
 Customer SPA will load on Shop page with [woonoow_shop] shortcode
 Other WooCommerce pages (Cart, Checkout, Account) still work
2025-12-30 18:02:48 +07:00
Dwindi Ramadhana
b6a0a66000 fix: Add SPA mounting point for full mode
Problem: Customer SPA not loading in 'full' mode
Root Cause: In full mode, SPA loads on WooCommerce pages without shortcodes, so there's no #woonoow-customer-app div for React to mount to

Solution: Inject mounting point div when in full mode via woocommerce_before_main_content hook

Changes:
- Added inject_spa_mount_point() method
- Hooks into woocommerce_before_main_content when in full mode
- Only injects if mount point doesn't exist from shortcode

Result:
 Full mode now has mounting point on WooCommerce pages
 Shortcode mode still works with shortcode-provided divs
 Customer SPA can now initialize properly
2025-12-30 17:54:12 +07:00
Dwindi Ramadhana
3260c8c112 debug: Add detailed logging to customer SPA asset loading
Added comprehensive logging to track:
- should_load_assets() decision flow
- SPA mode setting
- Post ID and content
- Shortcode detection
- Asset enqueue URLs
- Dev vs production mode

This will help identify why customer SPA is not loading.
2025-12-30 17:51:04 +07:00
Dwindi Ramadhana
0609c6e3d8 fix: Customer SPA loading and optimize production build size
Problem 1: Customer SPA not loading (stuck on 'Loading...')
Root Cause: Missing type='module' attribute on customer SPA script tag
Solution: Added script_loader_tag filter to inject type='module' for ES modules

Problem 2: Production zip too large (21-41MB)
Root Cause: Build script included unnecessary files (dist folder, fonts, .vite, test files, archives)
Solution:
- Exclude entire customer-spa and admin-spa directories from rsync
- Manually copy only app.js and app.css for both SPAs
- Exclude dist/, archive/, test-*.php, check-*.php files
- Simplified Frontend/Assets.php to always load app.js/app.css directly (no manifest needed)

Changes:
- includes/Frontend/Assets.php:
  * Added type='module' to customer SPA script (both manifest and fallback paths)
  * Removed manifest logic, always load app.js and app.css directly
- build-production.sh:
  * Exclude customer-spa and admin-spa directories completely
  * Manually copy only dist/app.js and dist/app.css
  * Exclude dist/, archive/, test files

Result:
 Customer SPA loads with type='module' support
 Production zip reduced from 21-41MB to 1.6MB
 Only essential files included (app.js + app.css for both SPAs)
 Clean production package without dev artifacts

Package contents:
- Customer SPA: 480K (app.js) + 52K (app.css) = 532K
- Admin SPA: 2.6M (app.js) + 76K (app.css) = 2.7M
- PHP Backend: ~500K
- Total: 1.6M (compressed)
2025-12-30 17:48:09 +07:00
Dwindi Ramadhana
447ca501c7 fix: Generate Vite manifest for customer SPA loading
Problem: Customer SPA stuck on 'Loading...' message after installation
Root Cause: Vite build wasn't generating manifest.json, causing WordPress asset loader to fall back to direct app.js loading without proper module configuration

Solution:
1. Added manifest: true to both SPA vite configs
2. Updated Assets.php to look for manifest in correct location (.vite/manifest.json)
3. Rebuilt both SPAs with manifest generation

Changes:
- customer-spa/vite.config.ts: Added manifest: true
- admin-spa/vite.config.ts: Added manifest: true
- includes/Frontend/Assets.php: Updated manifest path from 'manifest.json' to '.vite/manifest.json'

Build Output:
- Customer SPA: dist/.vite/manifest.json generated
- Admin SPA: dist/.vite/manifest.json generated
- Production zip: 10M (includes manifest files)

Result:
 Customer SPA now loads correctly via manifest
 Admin SPA continues to work
 Proper asset loading with CSS and JS from manifest
 Production package ready for deployment
2025-12-30 17:26:18 +07:00
Dwindi Ramadhana
863610043d fix: Dashboard always active + Full wishlist settings implementation
Dashboard Navigation Fix:
- Fixed ActiveNavLink to only activate Dashboard on / or /dashboard/* paths
- Dashboard no longer shows active when on other routes (Marketing, Settings, etc.)
- Proper path matching logic for all main menu items

Wishlist Settings - Full Implementation:
Backend (PHP):
1. Guest Wishlist Support
   - Modified check_permission() to allow guests if enable_guest_wishlist is true
   - Guests can now add/remove wishlist items (stored in user meta when they log in)

2. Max Items Limit
   - Added max_items_per_wishlist enforcement in add_to_wishlist()
   - Returns error when limit reached with helpful message
   - 0 = unlimited (default)

Frontend (React):
3. Show in Header Setting
   - Added useModuleSettings hook to customer-spa
   - Wishlist icon respects show_in_header setting (default: true)
   - Icon hidden when setting is false

4. Show Add to Cart Button Setting
   - Wishlist page checks show_add_to_cart_button setting
   - Add to cart buttons hidden when setting is false (default: true)
   - Allows wishlist-only mode without purchase prompts

Files Added (1):
- customer-spa/src/hooks/useModuleSettings.ts

Files Modified (5):
- admin-spa/src/App.tsx (dashboard active fix)
- includes/Frontend/WishlistController.php (guest support, max items)
- customer-spa/src/layouts/BaseLayout.tsx (show_in_header)
- customer-spa/src/pages/Account/Wishlist.tsx (show_add_to_cart_button)
- admin-spa/dist/app.js + customer-spa/dist/app.js (rebuilt)

Implemented Settings (4 of 8):
 enable_guest_wishlist - Backend permission check
 show_in_header - Frontend icon visibility
 max_items_per_wishlist - Backend validation
 show_add_to_cart_button - Frontend button visibility

Not Yet Implemented (4 of 8):
- wishlist_page (page selector - would need routing logic)
- enable_sharing (share functionality - needs share UI)
- enable_email_notifications (back in stock - needs cron job)
- enable_multiple_wishlists (multiple lists - needs data structure change)

All core wishlist settings now functional!
2025-12-26 21:57:56 +07:00
Dwindi Ramadhana
07020bc0dd feat: Implement centralized module management system
- Add ModuleRegistry for managing built-in modules (newsletter, wishlist, affiliate, subscription, licensing)
- Add ModulesController REST API for module enable/disable
- Create Modules settings page with category grouping and toggle controls
- Integrate module checks across admin-spa and customer-spa
- Add useModules hook for both SPAs to check module status
- Hide newsletter from footer builder when module disabled
- Hide wishlist features when module disabled (product cards, account menu, wishlist page)
- Protect wishlist API endpoints with module checks
- Auto-update navigation tree when modules toggled
- Clean up obsolete documentation files
- Add comprehensive documentation:
  - MODULE_SYSTEM_IMPLEMENTATION.md
  - MODULE_INTEGRATION_SUMMARY.md
  - ADDON_MODULE_INTEGRATION.md (proposal)
  - ADDON_MODULE_DESIGN_DECISIONS.md (design doc)
  - FEATURE_ROADMAP.md
  - SHIPPING_INTEGRATION.md

Module system provides:
- Centralized enable/disable for all features
- Automatic navigation updates
- Frontend/backend integration
- Foundation for addon-module unification
2025-12-26 19:19:49 +07:00
Dwindi Ramadhana
0b08ddefa1 feat: implement wishlist feature with admin toggle
- Add WishlistController with full CRUD API
- Create wishlist page in My Account
- Add heart icon to all product card layouts (always visible)
- Implement useWishlist hook for state management
- Add wishlist toggle in admin Settings > Customer
- Fix wishlist menu visibility based on admin settings
- Fix double navigation in wishlist page
- Fix variable product navigation to use React Router
- Add TypeScript type casting fix for addresses
2025-12-26 01:44:15 +07:00
Dwindi Ramadhana
100f9cce55 feat: implement multiple saved addresses with modal selector in checkout
- Add AddressController with full CRUD API for saved addresses
- Implement address management UI in My Account > Addresses
- Add modal-based address selector in checkout (Tokopedia-style)
- Hide checkout forms when saved address is selected
- Add search functionality in address modal
- Auto-select default addresses on page load
- Fix variable products to show 'Select Options' instead of 'Add to Cart'
- Add admin toggle for multiple addresses feature
- Clean up debug logs and fix TypeScript errors
2025-12-26 01:16:11 +07:00
Dwindi Ramadhana
9ac09582d2 feat: implement header/footer visibility controls for checkout and thankyou pages
- Created LayoutWrapper component to conditionally render header/footer based on route
- Created MinimalHeader component (logo only)
- Created MinimalFooter component (trust badges + policy links)
- Created usePageVisibility hook to get visibility settings per page
- Wrapped ClassicLayout with LayoutWrapper for conditional rendering
- Header/footer visibility now controlled directly in React SPA
- Settings: show/minimal/hide for both header and footer
- Background color support for checkout and thankyou pages
2025-12-25 22:20:48 +07:00
Dwindi Ramadhana
f397ef850f feat: Add product images support with WP Media Library integration
- Add WP Media Library integration for product and variation images
- Support images array (URLs) conversion to attachment IDs
- Add images array to API responses (Admin & Customer SPA)
- Implement drag-and-drop sortable images in Admin product form
- Add image gallery thumbnails in Customer SPA product page
- Initialize WooCommerce session for guest cart operations
- Fix product variations and attributes display in Customer SPA
- Add variation image field in Admin SPA

Changes:
- includes/Api/ProductsController.php: Handle images array, add to responses
- includes/Frontend/ShopController.php: Add images array for customer SPA
- includes/Frontend/CartController.php: Initialize WC session for guests
- admin-spa/src/lib/wp-media.ts: Add openWPMediaGallery function
- admin-spa/src/routes/Products/partials/tabs/GeneralTab.tsx: WP Media + sortable images
- admin-spa/src/routes/Products/partials/tabs/VariationsTab.tsx: Add variation image field
- customer-spa/src/pages/Product/index.tsx: Add gallery thumbnails display
2025-11-26 16:18:43 +07:00