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
This commit is contained in:
Dwindi Ramadhana
2026-01-07 22:26:58 +07:00
parent 2cc20ff760
commit 3a08e80c1f
2 changed files with 16 additions and 12 deletions

View File

@@ -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 (
<Container>
<div className="text-center py-16">
@@ -771,7 +771,7 @@ export default function Checkout() {
</div>
{/* Shipping Options */}
{elements.shipping_options && (
{!isVirtualOnly && elements.shipping_options && (
<div className="mb-4 pb-4 border-b">
<h3 className="font-medium mb-3">Shipping Method</h3>
<div className="space-y-2">
@@ -806,10 +806,12 @@ export default function Checkout() {
<span>-{formatPrice(discountTotal)}</span>
</div>
)}
<div className="flex justify-between text-sm">
<span>Shipping</span>
<span>{shipping === 0 ? 'Free' : formatPrice(shipping)}</span>
</div>
{!isVirtualOnly && (
<div className="flex justify-between text-sm">
<span>Shipping</span>
<span>{shipping === 0 ? 'Free' : formatPrice(shipping)}</span>
</div>
)}
{tax > 0 && (
<div className="flex justify-between text-sm">
<span>Tax</span>