Item Unavailable
Sometimes you may want to check if an item is unavailable and whether you should disable your add to cart or buy now button. The following helpers are available to help with this.
isItemSoldOut
isItemSoldOut
takes an item resource and checks whether all variations for the item are marked as sold out or have an inventory of 0 (if inventory tracking is enabled).
const isItemSoldOut = sdk.helpers.item.isItemSoldOut(item);
isEventItemInThePast
isEventItemInThePast
takes an item resource and checks whether the event end date is in the past (e.g. before now). If the square_online_type
is not EVENT
, false is returned.
const isEventItemInThePast = sdk.helpers.item.isEventItemInThePast(item);
isPreorderItemCutoffInThePast
isPreorderItemCutoffInThePast
takes an item resource and checks whether the preorder availability cutoff at time is in the past (e.g. before now). If the item doesn’t support preordering pickup, false is returned. Note that the SHIPMENT
fulfillment isn’t supported for preorders and this function doesn’t take the buyer’s selected fulfillment into account.
const isPreorderItemCutoffInThePast = sdk.helpers.item.isPreorderItemCutoffInThePast(item);