From 3a08e80c1f827c0f6fd3cd4dcd4157b3c98a5a7f Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Wed, 7 Jan 2026 22:26:58 +0700 Subject: [PATCH] fix: category selection, checkout redirect, sidebar shipping visibility 1. Category Selection Bug: - Added 'id' alias to category/tag API responses - Frontend uses cat.id which was undefined (API returned term_id) 2. Checkout Redirect: - Changed from window.location.href + reload to navigate() - Added !isProcessing check to empty cart condition 3. Sidebar Shipping for Virtual-Only: - Hide Shipping Method section when isVirtualOnly - Hide Shipping row in totals when isVirtualOnly 4. License Table: - Table creation runs via ensure_tables() on plugins_loaded --- customer-spa/src/pages/Checkout/index.tsx | 26 ++++++++++++----------- includes/Api/ProductsController.php | 2 ++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/customer-spa/src/pages/Checkout/index.tsx b/customer-spa/src/pages/Checkout/index.tsx index 7974819..5502d9c 100644 --- a/customer-spa/src/pages/Checkout/index.tsx +++ b/customer-spa/src/pages/Checkout/index.tsx @@ -304,11 +304,11 @@ export default function Checkout() { toast.success('Order placed successfully!'); - // Use full page reload instead of SPA routing - // This ensures auto-registered users get their auth cookies properly set - const thankYouUrl = `${window.location.origin}/store/#/order-received/${data.order_id}?key=${data.order_key}`; - window.location.href = thankYouUrl; - window.location.reload(); + // Navigate to thank you page via SPA routing + // Using window.location.replace to prevent back button issues + const thankYouUrl = `/order-received/${data.order_id}?key=${data.order_key}`; + navigate(thankYouUrl, { replace: true }); + return; // Stop execution here } else { throw new Error(data.error || 'Failed to create order'); } @@ -320,8 +320,8 @@ export default function Checkout() { } }; - // Empty cart redirect - if (cart.items.length === 0) { + // Empty cart redirect (but only if not processing) + if (cart.items.length === 0 && !isProcessing) { return (
@@ -771,7 +771,7 @@ export default function Checkout() {
{/* Shipping Options */} - {elements.shipping_options && ( + {!isVirtualOnly && elements.shipping_options && (

Shipping Method

@@ -806,10 +806,12 @@ export default function Checkout() { -{formatPrice(discountTotal)}
)} -
- Shipping - {shipping === 0 ? 'Free' : formatPrice(shipping)} -
+ {!isVirtualOnly && ( +
+ Shipping + {shipping === 0 ? 'Free' : formatPrice(shipping)} +
+ )} {tax > 0 && (
Tax diff --git a/includes/Api/ProductsController.php b/includes/Api/ProductsController.php index c83b328..1d45c21 100644 --- a/includes/Api/ProductsController.php +++ b/includes/Api/ProductsController.php @@ -621,6 +621,7 @@ class ProductsController { $categories = []; foreach ($terms as $term) { $categories[] = [ + 'id' => $term->term_id, 'term_id' => $term->term_id, 'name' => $term->name, 'slug' => $term->slug, @@ -649,6 +650,7 @@ class ProductsController { $tags = []; foreach ($terms as $term) { $tags[] = [ + 'id' => $term->term_id, 'term_id' => $term->term_id, 'name' => $term->name, 'slug' => $term->slug,