Constructor Summary
| Public Constructor | ||
| public |
Construct a new instance of the cart entity. |
|
Member Summary
| Public Members | ||
| public get |
Alias to getAttributes() |
|
| public get |
Alias to getItems(); |
|
| public get |
Alias to getTotalPrice(); |
|
| public get |
Alias to getTotalPrice(); |
|
| Private Members | ||
| private |
_attributes: {} |
|
| private |
|
|
| private |
|
|
| private |
|
|
Method Summary
| Public Methods | ||
| public |
addItem(id: Number | String, quantity: Number, properties: Object): Promise<ShopifyCartLineItem, Error> Add a new item to the cart. |
|
| public |
Clear the cart. |
|
| public |
getAttribute(key: *): * |
|
| public |
Returns cart attributes. |
|
| public |
Returns items in the cart (in the normal Shopify line item format. |
|
| public |
Calculates the total value of the cart. |
|
| public |
initialize(cartData: ShopifyCart) Initialize the cart entity with the current state of the visitor's cart. |
|
| public |
Reloads the cart state via AJAX. |
|
| public |
removeItem(lineNumber: *): * |
|
| public |
removeItemById(id: *): * |
|
| public |
setAttribute(key: *, value: *): * |
|
| public |
setAttributes(attributes: Object): Promise<Cart, Error> Sets all attributes on the cart. |
|
| public |
updateItem(lineNumber: *, quantity: *, properties: *): * |
|
| public |
updateItemById(id: *, quantity: *, properties: *): * |
|
| public |
updateItemById(id: *, quantity: *, properties: *): * |
|
| public |
updateItemQuantitiesById(updates: *): * |
|
| Private Methods | ||
| private |
_emitAdd(item: *) |
|
| private |
_emitClear(oldItems: *) |
|
| private |
_emitRemove(item: *) |
|
| private |
_emitUpdate(operation: *, item: *) |
|
| private |
_emitUpdateItem(item: *) |
|
| private |
_loadFromShopifyCart(cart: *) |
|
| private |
_loadItem(itemData: *): * |
|
Public Constructors
Public Methods
public addItem(id: Number | String, quantity: Number, properties: Object): Promise<ShopifyCartLineItem, Error> source
Add a new item to the cart.
public getItems(): ShopifyCartLineItem[] source
Returns items in the cart (in the normal Shopify line item format.
public initialize(cartData: ShopifyCart) source
Initialize the cart entity with the current state of the visitor's cart.
Params:
| Name | Type | Attribute | Description |
| cartData | ShopifyCart | Shopify Cart object. |
public removeItem(lineNumber: *): * source
Params:
| Name | Type | Attribute | Description |
| lineNumber | * |
Return:
| * |
public setAttribute(key: *, value: *): * source
Params:
| Name | Type | Attribute | Description |
| key | * | ||
| value | * |
Return:
| * |
public setAttributes(attributes: Object): Promise<Cart, Error> source
Sets all attributes on the cart. This will override/remove existing attributes.
Params:
| Name | Type | Attribute | Description |
| attributes | Object | New attributes for the cart. |
public updateItem(lineNumber: *, quantity: *, properties: *): * source
Params:
| Name | Type | Attribute | Description |
| lineNumber | * | ||
| quantity | * | ||
| properties | * |
Return:
| * |
public updateItemById(id: *, quantity: *, properties: *): * source
Params:
| Name | Type | Attribute | Description |
| id | * | ||
| quantity | * | ||
| properties | * |
Return:
| * |
public updateItemById(id: *, quantity: *, properties: *): * source
Params:
| Name | Type | Attribute | Description |
| id | * | ||
| quantity | * | ||
| properties | * |
Return:
| * |
public updateItemQuantitiesById(updates: *): * source
Params:
| Name | Type | Attribute | Description |
| updates | * |
Return:
| * |
Private Methods
private _emitAdd(item: *) source
Params:
| Name | Type | Attribute | Description |
| item | * |
private _emitClear(oldItems: *) source
Params:
| Name | Type | Attribute | Description |
| oldItems | * |
private _emitRemove(item: *) source
Params:
| Name | Type | Attribute | Description |
| item | * |
private _emitUpdate(operation: *, item: *) source
Params:
| Name | Type | Attribute | Description |
| operation | * | ||
| item | * |
private _emitUpdateItem(item: *) source
Params:
| Name | Type | Attribute | Description |
| item | * |
private _loadFromShopifyCart(cart: *) source
Params:
| Name | Type | Attribute | Description |
| cart | * |