work-around minimum order value

Whilst this feature is being voted on, I have implemented the following code on the Cart page :

import wixWindow from ‘wix-window’ ;
import { getCurrentCart } from ‘backend/cart.jsw’ ;

const MINIMUM_AMOUNT = 25 ;

$w . onReady ( function () {
checkMinAmount ();

async function checkMinAmount () {
let cart = await getCurrentCart ();
if ( cart . totals . subtotal < MINIMUM_AMOUNT ) {
wixWindow . openLightbox ( ‘Minimum Order Notification’ );

When a customer spends less than the required minimum, upon checkout a full screen lightbox opens up advising they need to continue purchasing and a button with a link takes them back to the Shop All page.

However, if the client purchases above the minimum order amount, they are taken to check out to process payment. If they decide at that point to lower the order or delete an item that takes the total order value BELOW the minimum order value, then they can proceed through checkout.

I would like to put in some code that is attached to the total order value of goods that says 'refresh this page if it falls below ‘x’ amount.

I’ve tested the cart page when the dollar value is below the minimum amount and refreshed it manually. It brings up the lightbox stating they need to order the minimum amount.

I’m missing the autorefresh which would be triggered by the next piece of code.

I would appreciate any assistance with this.

Maybe you can use ‘setInterval’ ? This helps you to repeat the check process again and again.

One more thing, you can collapse the cart element so the customer won’t be able to ‘remove’ the lightbox from broswer developer tools. (reduce the chance of ‘leak’)

setInterval(function(){ alert("Hello"); }, 3000);

Try it Yourself »

Thank you… I’ll give it a try.