My store sells products of 3 different categories. I want to prevent checkout if there are either:
- More than 5 items of a certain category
OR
2. More than 4Liters shipping weight of a certain category
OR
3. More than $200 in subtotal (pre-tax) for a certain category
I added the following code but it returns with a “Cart not found” when I run it.
Cart.jsw
import wixStores from ‘wix-stores-backend’;
export function getCurrentCart() {
const cart = wixStores.getCurrentCart()
return cart;
}
Cart page
import wixWindow from ‘wix-window’;
import { getCurrentCart } from ‘backend/cart.jsw’;
const MAXIMUM_AMOUNT = 200;
$w.onReady( function () {
checkMaxAmount();
});
async function checkMaxAmount() {
let cart = await getCurrentCart();
if (cart.totals.subtotal > MAXIMUM_AMOUNT) {
wixWindow.openLightbox(‘Maximum Order Notification’);
}
}
I’m not JS proficient so any help would be appreciated.
Thanks