- 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
1.4 KiB
1.4 KiB
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:
Frontend\CartController- Old static methodsApi\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
// 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
- Added alias
ApiCartControllerfor new cart API - Changed instance creation to use alias
- Changed frontend call to use
FrontendCartControlleralias
Result
✅ No more naming conflict ✅ Both controllers work correctly ✅ Shop page loads successfully ✅ Products display properly
Test
- Refresh shop page
- Should load without 500 error
- Products should display
- Add to cart should work