@square/site-theme-sdk / Modules / helpers/item / Item
helpers/item.Item
- getVariations
- getItemOptions
- getModifierLists
- isVariationSoldOut
- getItemQuantityError
- isItemSoldOut
- getInStockVariationsForSelectedOptionsOrVariation
- isOptionChoiceDisabledForSelectedOptions
- isModifierListForSelectedModifiersValid
- getDisabledOptionChoicesForSelectedOptions
- validateItem
- getItemPrice
- isEventItemInThePast
- isPreorderItemCutoffInThePast
- parsePrepTime
• new Item()
▸ getVariations(item
): Variation
[]
Returns the variations for an item resource.
Name | Type |
---|---|
item |
Item |
▸ getItemOptions(item
): undefined
| ItemOption
[]
Returns the item options for an item resource.
Name | Type |
---|---|
item |
Item |
undefined
| ItemOption
[]
▸ getModifierLists(item
): undefined
| ModifierList
[]
Returns the modifier lists for an item resource.
Name | Type |
---|---|
item |
Item |
undefined
| ModifierList
[]
▸ isVariationSoldOut(variation
): boolean
Returns whether a particular variation is sold out.
Name | Type |
---|---|
variation |
Variation |
boolean
▸ getItemQuantityError(item
, variation
, quantity
): null
| QuantityErrorTypeEnum
Returns the QuantityErrorType if there's an item quantity error with the item varation, otherwise null.
Name | Type |
---|---|
item |
Item |
variation |
Variation |
quantity |
number |
null
| QuantityErrorTypeEnum
▸ isItemSoldOut(item
): boolean
Returns whether all variations of an item are sold out.
Name | Type |
---|---|
item |
Item |
boolean
▸ getInStockVariationsForSelectedOptionsOrVariation(«destructured»
): Variation
[]
Returns all variations in stock for the selected options or variation.
Name | Type |
---|---|
«destructured» |
GetInStockVariationsForSelectedOptionsOrVariationRequest |
▸ isOptionChoiceDisabledForSelectedOptions(item
, optionChoice
, selectedOptions
, removeMatchingOptionSet?
): boolean
Returns whether an item's option choice is disabled based on the selected options.
Name | Type | Default value |
---|---|---|
item |
Item |
undefined |
optionChoice |
OptionSelection |
undefined |
selectedOptions |
OptionSelection [] |
undefined |
removeMatchingOptionSet |
boolean |
true |
boolean
▸ isModifierListForSelectedModifiersValid(modifierList
, selectedModifiers
): boolean
Returns whether a modifier list is valid for the selected modifiers.
Name | Type |
---|---|
modifierList |
ModifierList |
selectedModifiers |
AddItemModifier [] |
boolean
▸ getDisabledOptionChoicesForSelectedOptions(item
, itemOption
, selectedOptions
, removeMatchingOptionSet?
): string
[]
Returns the disabled option choices for an item based on the selected options.
Name | Type | Default value |
---|---|---|
item |
Item |
undefined |
itemOption |
ItemOption |
undefined |
selectedOptions |
OptionSelection [] |
undefined |
removeMatchingOptionSet |
boolean |
true |
string
[]
▸ validateItem(«destructured»
): AddLineItem
Returns whether an item with any combination of selected options, modifiers, variationId, and quantity is valid.
Name | Type |
---|---|
«destructured» |
ValidateItemRequest |
Throws
▸ getItemPrice(«destructured»
): null
| ItemPrice
Returns the price of an item based on the selected options, modifiers, and/or variation id.
Name | Type |
---|---|
«destructured» |
GetItemPriceRequest |
null
| ItemPrice
▸ isEventItemInThePast(item
): boolean
Returns whether an item is an event and has ended.
Name | Type |
---|---|
item |
Item |
boolean
▸ isPreorderItemCutoffInThePast(item
): boolean
Returns whether an item is a preorder and the cutoff time has passed.
Name | Type |
---|---|
item |
Item |
boolean
▸ parsePrepTime(prepTimeDuration
): null
| ItemPrepTime
Returns the item's prep time duration parsed into value, unit, is_time. is_time means prep duration includes a time component (hour/minute/second). It's used to differentiate '4M' between '4 months' and '4 minutes' Note that this function relies on the fact that prepTimeDuration currently only supports a single time unit! I.e. P2DT6H20M is not currently supported and will not work.
Name | Type |
---|---|
prepTimeDuration |
string |
null
| ItemPrepTime