top of page
Writer's pictureAshwani Agarwal

Minimum Order Quantity: Now Solved with Wix Velo!

Updated: May 6


MOQ in Wix.

Try out this live example on Wix Minimum Order Quantity


INTRODUCTION

In the world of e-commerce, businesses are always looking for innovative ways to meet the unique needs of their customers. One such game-changing feature is offering customized Minimum Order Quantities (MOQs). However, implementing custom MOQs on a website can be challenging without technical expertise. Luckily, with Wix Velo, the powerful and user-friendly development platform by Wix, solving this challenge becomes much easier. Prepare to unlock a new level of flexibility and cater to your specific quantity supply per customer with Wix Velo's custom MOQs.


To configure customized MOQ to your online store, apply the following code on the cart page of your Wix Stores.


import { cart } from 'wix-stores';
import wixWindow from 'wix-window';
import { getMoq } from "backend/cart.jsw"

$w.onReady(async function () {
  let ProductLessThanMoq = [];
  const cartProduct = await cart.getCurrentCart();
  const lineItems = cartProduct.lineItems;

  await Promise.all(lineItems.map(async (item) => {
    const quantity = item.quantity;
    const itemid = item.productId;
    const moqData = await getMoq(itemid);
    if (quantity < moqData.moq) {
      ProductLessThanMoq.push(item); 
      console.log(item, `because it is less than moq ${moqData.moq - quantity}`);
      wixWindow.openLightbox("LightBox",ProductLessThanMoq)
    } else if (quantity >= moqData.moq) {
      console.log(`You can go to checkout because it is equal to your MOQ which is ${moqData.moq}`);
    } else {
      console.log("You can go to checkout");
    }
  }));
});

With this simple process, configuring customized MOQ is made easier and hassle-free. Troubleshoot issues if the code isn't implemented.


Note: It's now possible to limit the sale of a specific item to a minimum quantity (e.g. minimum order is 6 unicorn mugs) and/or a maximum quantity using Wix Checkout Requirements app.

For further assistance, hire a wix expert.



258 views0 comments

Comments


bottom of page