Wix Stores: Prevent Checkout if over a certain quantity

My store sells products of 3 different categories. I want to prevent checkout if there are either:

  1. More than 5 items of a certain category


 2. More than 4Liters shipping weight of a certain category 


 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.


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 () {

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.