From 677c04dd6208f27f8dea2541d792e551cd732321 Mon Sep 17 00:00:00 2001 From: dwindown Date: Tue, 11 Nov 2025 10:14:09 +0700 Subject: [PATCH] fix: Add tagline to Login branding state + troubleshooting doc --- CUSTOMER_SETTINGS_404_FIX.md | 131 +++++++++++++++++++++++++++++++++ admin-spa/src/routes/Login.tsx | 2 + 2 files changed, 133 insertions(+) create mode 100644 CUSTOMER_SETTINGS_404_FIX.md diff --git a/CUSTOMER_SETTINGS_404_FIX.md b/CUSTOMER_SETTINGS_404_FIX.md new file mode 100644 index 0000000..ed70b33 --- /dev/null +++ b/CUSTOMER_SETTINGS_404_FIX.md @@ -0,0 +1,131 @@ +# Customer Settings 404 Error - Troubleshooting Guide + +## Issue +The `/store/customer-settings` endpoint returns 404 error. + +## Verification Steps + +### 1. Check if routes are registered +The routes ARE correctly registered in `includes/Api/StoreController.php`: +- Line 90-97: GET `/woonoow/v1/store/customer-settings` +- Line 99-106: POST `/woonoow/v1/store/customer-settings` + +### 2. Check if controller is initialized +The controller IS initialized in `includes/Api/Routes.php`: +- Line 56-57: `new StoreController()` and `register_routes()` + +### 3. Check if class exists +The `CustomerSettingsProvider` class EXISTS in: +- `includes/Compat/CustomerSettingsProvider.php` +- Namespace: `WooNooW\Compat` + +## Possible Causes & Solutions + +### Solution 1: Flush WordPress Permalinks +WordPress may need to rebuild its rewrite rules. + +**Via WP-Admin:** +1. Go to Settings → Permalinks +2. Click "Save Changes" (no need to change anything) + +**Via WP-CLI:** +```bash +wp rewrite flush +``` + +### Solution 2: Check Debug Logs +Debug logging has been added to track the issue: + +**Enable WordPress Debug:** +Add to `wp-config.php`: +```php +define('WP_DEBUG', true); +define('WP_DEBUG_LOG', true); +define('WP_DEBUG_DISPLAY', false); +``` + +**Check logs:** +```bash +tail -f wp-content/debug.log +``` + +Look for: +- `WooNooW: get_customer_settings called` +- `WooNooW: Customer settings retrieved: ...` +- `WooNooW: get_customer_settings exception: ...` + +### Solution 3: Test Endpoint Directly +Open browser console and run: +```javascript +fetch(window.WNW_CONFIG.restUrl + '/store/customer-settings', { + headers: { + 'X-WP-Nonce': window.wpApiSettings.nonce + } +}) +.then(r => r.json()) +.then(console.log) +.catch(console.error); +``` + +### Solution 4: Verify REST API is Working +Test a known endpoint: +```javascript +fetch(window.WNW_CONFIG.restUrl + '/store/branding') +.then(r => r.json()) +.then(console.log); +``` + +If this fails, the REST API itself may be broken. + +### Solution 5: Check .htaccess +Ensure `.htaccess` has WordPress rewrite rules: +```apache +# BEGIN WordPress + +RewriteEngine On +RewriteBase / +RewriteRule ^index\.php$ - [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule . /index.php [L] + +# END WordPress +``` + +## Expected Behavior + +**GET Request:** +```json +{ + "vip_min_spent": 1000, + "vip_min_orders": 10, + "vip_timeframe": "all", + "vip_require_both": true, + "vip_exclude_refunded": true +} +``` + +**POST Request:** +```json +{ + "success": true, + "message": "Customer settings updated successfully", + "settings": { ... } +} +``` + +## Quick Fix Checklist +- [ ] Flush permalinks +- [ ] Enable debug logging +- [ ] Check debug.log for errors +- [ ] Test endpoint in browser console +- [ ] Verify other REST endpoints work +- [ ] Check .htaccess file +- [ ] Clear all caches (browser, WordPress, server) + +## Still Not Working? +If none of the above works, there may be: +1. Plugin conflict (disable other plugins temporarily) +2. Theme conflict (switch to default theme temporarily) +3. Server configuration issue (check with hosting provider) +4. WordPress REST API disabled by security plugin diff --git a/admin-spa/src/routes/Login.tsx b/admin-spa/src/routes/Login.tsx index ef62afa..19acd5a 100644 --- a/admin-spa/src/routes/Login.tsx +++ b/admin-spa/src/routes/Login.tsx @@ -16,6 +16,7 @@ export function Login() { logo: '', logoDark: '', storeName: 'WooNooW', + tagline: '', }); const [isDark, setIsDark] = React.useState(false); const navigate = useNavigate(); @@ -46,6 +47,7 @@ export function Login() { logo: data.store_logo || '', logoDark: data.store_logo_dark || '', storeName: data.store_name || 'WooNooW', + tagline: data.store_tagline || '', }); }) .catch(err => console.error('Failed to load branding:', err));