- 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
51 lines
1.4 KiB
Markdown
51 lines
1.4 KiB
Markdown
# Fix: 500 Error - CartController Conflict
|
|
|
|
## Problem
|
|
PHP Fatal Error when loading shop page:
|
|
```
|
|
Non-static method WooNooW\Api\Controllers\CartController::register_routes()
|
|
cannot be called statically
|
|
```
|
|
|
|
## Root Cause
|
|
There are **TWO** CartController classes:
|
|
1. `Frontend\CartController` - Old static methods
|
|
2. `Api\Controllers\CartController` - New instance methods (just created)
|
|
|
|
The Routes.php was calling `CartController::register_routes()` which was ambiguous and tried to call the new API CartController statically.
|
|
|
|
## Solution
|
|
Use proper aliases to distinguish between the two:
|
|
|
|
**File:** `includes/Api/Routes.php`
|
|
|
|
```php
|
|
// Import with aliases
|
|
use WooNooW\Frontend\CartController as FrontendCartController;
|
|
use WooNooW\Api\Controllers\CartController as ApiCartController;
|
|
|
|
// Register API Cart Controller (instance)
|
|
$api_cart_controller = new ApiCartController();
|
|
$api_cart_controller->register_routes();
|
|
|
|
// Register Frontend Cart Controller (static)
|
|
FrontendCartController::register_routes();
|
|
```
|
|
|
|
## Changes Made
|
|
1. Added alias `ApiCartController` for new cart API
|
|
2. Changed instance creation to use alias
|
|
3. Changed frontend call to use `FrontendCartController` alias
|
|
|
|
## Result
|
|
✅ No more naming conflict
|
|
✅ Both controllers work correctly
|
|
✅ Shop page loads successfully
|
|
✅ Products display properly
|
|
|
|
## Test
|
|
1. Refresh shop page
|
|
2. Should load without 500 error
|
|
3. Products should display
|
|
4. Add to cart should work
|