Skip to content

Latest commit

 

History

History
321 lines (189 loc) · 8.5 KB

helpers_item.Item.md

File metadata and controls

321 lines (189 loc) · 8.5 KB

@square/site-theme-sdk / Modules / helpers/item / Item

Class: Item

helpers/item.Item

Table of contents

Constructors

Methods

Constructors

constructor

new Item()

Methods

getVariations

getVariations(item): Variation[]

Returns the variations for an item resource.

Parameters

Name Type
item Item

Returns

Variation[]


getItemOptions

getItemOptions(item): undefined | ItemOption[]

Returns the item options for an item resource.

Parameters

Name Type
item Item

Returns

undefined | ItemOption[]


getModifierLists

getModifierLists(item): undefined | ModifierList[]

Returns the modifier lists for an item resource.

Parameters

Name Type
item Item

Returns

undefined | ModifierList[]


isVariationSoldOut

isVariationSoldOut(variation): boolean

Returns whether a particular variation is sold out.

Parameters

Name Type
variation Variation

Returns

boolean


getItemQuantityError

getItemQuantityError(item, variation, quantity): null | QuantityErrorTypeEnum

Returns the QuantityErrorType if there's an item quantity error with the item varation, otherwise null.

Parameters

Name Type
item Item
variation Variation
quantity number

Returns

null | QuantityErrorTypeEnum


isItemSoldOut

isItemSoldOut(item): boolean

Returns whether all variations of an item are sold out.

Parameters

Name Type
item Item

Returns

boolean


getInStockVariationsForSelectedOptionsOrVariation

getInStockVariationsForSelectedOptionsOrVariation(«destructured»): Variation[]

Returns all variations in stock for the selected options or variation.

Parameters

Name Type
«destructured» GetInStockVariationsForSelectedOptionsOrVariationRequest

Returns

Variation[]


isOptionChoiceDisabledForSelectedOptions

isOptionChoiceDisabledForSelectedOptions(item, optionChoice, selectedOptions, removeMatchingOptionSet?): boolean

Returns whether an item's option choice is disabled based on the selected options.

Parameters

Name Type Default value
item Item undefined
optionChoice OptionSelection undefined
selectedOptions OptionSelection[] undefined
removeMatchingOptionSet boolean true

Returns

boolean


isModifierListForSelectedModifiersValid

isModifierListForSelectedModifiersValid(modifierList, selectedModifiers): boolean

Returns whether a modifier list is valid for the selected modifiers.

Parameters

Name Type
modifierList ModifierList
selectedModifiers AddItemModifier[]

Returns

boolean


getDisabledOptionChoicesForSelectedOptions

getDisabledOptionChoicesForSelectedOptions(item, itemOption, selectedOptions, removeMatchingOptionSet?): string[]

Returns the disabled option choices for an item based on the selected options.

Parameters

Name Type Default value
item Item undefined
itemOption ItemOption undefined
selectedOptions OptionSelection[] undefined
removeMatchingOptionSet boolean true

Returns

string[]


validateItem

validateItem(«destructured»): AddLineItem

Returns whether an item with any combination of selected options, modifiers, variationId, and quantity is valid.

Parameters

Name Type
«destructured» ValidateItemRequest

Returns

AddLineItem

Throws

ValidateItemError


getItemPrice

getItemPrice(«destructured»): null | ItemPrice

Returns the price of an item based on the selected options, modifiers, and/or variation id.

Parameters

Name Type
«destructured» GetItemPriceRequest

Returns

null | ItemPrice


isEventItemInThePast

isEventItemInThePast(item): boolean

Returns whether an item is an event and has ended.

Parameters

Name Type
item Item

Returns

boolean


isPreorderItemCutoffInThePast

isPreorderItemCutoffInThePast(item): boolean

Returns whether an item is a preorder and the cutoff time has passed.

Parameters

Name Type
item Item

Returns

boolean


parsePrepTime

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.

Parameters

Name Type
prepTimeDuration string

Returns

null | ItemPrepTime