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:
@@ -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>
|
||||
)}
|
||||
{!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>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user