Cart fixes (backend), adjusted header, added footer, mobile formatting updates
This commit is contained in:
@@ -85,6 +85,7 @@ export default function CartPage() {
|
||||
clearCart,
|
||||
applyCoupon,
|
||||
checkout,
|
||||
cancelCheckout,
|
||||
} = useCart();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -114,6 +115,14 @@ export default function CartPage() {
|
||||
}
|
||||
}, [cart]);
|
||||
|
||||
// If the cart arrives already locked (e.g. user closed the page mid-checkout)
|
||||
// and there is no active Stripe session, release the lock automatically.
|
||||
useEffect(() => {
|
||||
if (cart?.checkoutPending && !clientSecret) {
|
||||
cancelCheckout().catch(() => {});
|
||||
}
|
||||
}, [cart?.checkoutPending, clientSecret, cancelCheckout]);
|
||||
|
||||
async function handleQuantityChange(cartItemId, newQty) {
|
||||
if (newQty < 1) {
|
||||
return;
|
||||
@@ -351,7 +360,10 @@ export default function CartPage() {
|
||||
setClientSecret(null);
|
||||
setConfirmed(true);
|
||||
}}
|
||||
onCancel={() => setClientSecret(null)}
|
||||
onCancel={async () => {
|
||||
await cancelCheckout().catch(() => {});
|
||||
setClientSecret(null);
|
||||
}}
|
||||
/>
|
||||
</Elements>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user