Namespace: cart

utils.cart

The namespace representing the shopping cart. All static members of this namespace allow for the manipulation of a users shopping cart and aid in the checkout.

Example

cart.setCoupon('summersale2020').then(() => alert('Your coupon has been updated!'));

cart.setBilling({
    name: 'Kobe Bryant'
}).then(() => alert('Your billing information has been updated!'));

Methods

(static) addOem(params)

Parameters:
Name Type Description
params

(static) calculate() → {Promise.<Object>}

Calculate the totals for the cart based on submitted information.
Returns:
Type
Promise.<Object>

(static) clear() → {Promise.<*>}

Empty the cart of all items and clear all user data.
Returns:
Type
Promise.<*>

(static) get() → {Promise.<Array>}

Returns:
Returns a promise that resolves to an array of objects containing cart item details.
Type
Promise.<Array>

(static) getBilling() → {Promise.<(Object|null)>}

Returns:
Type
Promise.<(Object|null)>

(static) getCoupon() → {Promise.<(string|null)>}

Returns:
Type
Promise.<(string|null)>

(async, static) getPayload() → {Promise.<{paymentToken: (Object|string), cartCoupon: string, shipping: Object, shippingMethod: (Object|null), cartItems: Array, billing: Object}>}

Gets a properly formatted payload for `CartCalculationService`
Returns:
Type
Promise.<{paymentToken: (Object|string), cartCoupon: string, shipping: Object, shippingMethod: (Object|null), cartItems: Array, billing: Object}>

(static) getPaymentToken() → {Promise.<(null|Object|string)>}

Returns:
Type
Promise.<(null|Object|string)>

(static) getShipping() → {Promise.<(Object|null)>}

Returns:
Type
Promise.<(Object|null)>

(static) getShippingMethod() → {Promise.<(Object|null)>}

Returns:
Type
Promise.<(Object|null)>

(static) getZip() → {Promise.<(string|null)>}

Returns:
Type
Promise.<(string|null)>

(static) setBilling(user) → {Promise.<*>}

Parameters:
Name Type Description
user Object
Returns:
Type
Promise.<*>

(static) setCoupon(couponCode) → {Promise.<*>}

Parameters:
Name Type Description
couponCode
Returns:
Type
Promise.<*>

(static) setPaymentToken(token) → {Promise.<*>}

Parameters:
Name Type Description
token Object | string
Returns:
Type
Promise.<*>

(static) setShipping(shippingAddress) → {Promise.<*>}

Parameters:
Name Type Description
shippingAddress Object
Returns:
Type
Promise.<*>

(static) setShippingMethod(shippingMethod) → {Promise.<*>}

Parameters:
Name Type Description
shippingMethod Object | null An object containing the shipment and rate to use, or null for none - reference_id - The reference ID to the rate - shipment_package_id - The reference ID to the shipment package
Returns:
Type
Promise.<*>

(static) setZip(zip) → {Promise.<*>}

Parameters:
Name Type Description
zip
Returns:
Type
Promise.<*>

(static) shippingRates() → {Promise.<Array>}

Retrieves all applicable shipping rates based on cart data
Returns:
Type
Promise.<Array>