Cart/Methods

Cart/Methods

Source:

Methods for Cart - Use these methods by running Meteor.call()

Example

Meteor.call("cart/createCart")

Methods

(static) cart/addToCart(cartId, tokenopt, items) → {Object}

Add items to a user cart. When we add an item to the cart, we want to break all relationships with the existing item. We want to fix price, qty, etc into history. However, we could check reactively for price /qty etc, adjustments on the original and notify them.

Source:
Parameters:
Name Type Attributes Description
cartId String

The cart ID

token String <optional>

The cart token, if it's an anonymous cart

items Array.<Object>

An array of cart items to add to the new cart. Must not be empty.

Returns:

An object with the updated cart document (cart), incorrectPriceFailures, and minOrderQuantityFailures

Type
Object

(static) cart/createCart(items) → {Object}

create new cart for user

Source:
Parameters:
Name Type Description
items Array.<Object>

An array of cart items to add to the new cart. Must not be empty.

Returns:

The object returned by createCart mutation

Type
Object

(static) cart/mergeCart(anonymousCartId, anonymousCartToken) → {Object|Boolean}

Merge anonymous cart into specified account cart There should be one cart for each independent, non-logged-in user session. When a user logs in that cart now belongs to that user and we use the a single user cart. If they are logged in on more than one devices, regardless of session,the user cart will be used If they had more than one cart, on more than one device,logged in at separate times then merge the carts

Source:
Parameters:
Name Type Description
anonymousCartId String

Cart ID of the cart to merge FROM and then delete

anonymousCartToken String

Token granting access to the anonymous cart

Returns:

cartId - cartId on success or false

Type
Object | Boolean

(static) cart/removeFromCart(cartId, cartTokenopt, cartItemId, quantityDecrementopt) → {Object}

Removes or adjust quantity of a variant from the cart

Source:
Parameters:
Name Type Attributes Description
cartId String

Cart ID

cartToken String <optional>

Token for cart, if it's anonymous

cartItemId String

cart item _id

quantityDecrement Number <optional>

if provided will decrement quantity by quantityDecrement

Returns:

An object with cart property set to the updated Cart document

Type
Object

(static) cart/setPaymentAddress(cartId, cartTokenopt, address) → {Number}

Adds address book to cart payments

Source:
To Do:
  • maybe we need to rename this method to `cart/setBillingAddress`?
Parameters:
Name Type Attributes Description
cartId String

cartId to apply payment address

cartToken String <optional>

Token for cart, if it's anonymous

address Object

addressBook object

Returns:

return Mongo update result

Type
Number

(static) cart/setShipmentAddress(cartId, cartTokenopt, address) → {Number}

Adds address book to cart shipping

Source:
Parameters:
Name Type Attributes Description
cartId String

The ID of the cart on which to set shipping address

cartToken String <optional>

Token for cart, if it's anonymous

address Object

addressBook object

Returns:

update result

Type
Number

(static) cart/setShipmentMethod(cartId, cartTokenopt, methodId) → {undefined}

Saves method as order default

Source:
Parameters:
Name Type Attributes Description
cartId String

cartId to apply shipment method

cartToken String <optional>

Token for cart, if it's anonymous

methodId String

The selected method ID

Returns:
Type
undefined

(static) cart/setUserCurrency(cartId, cartTokenopt, userCurrency) → {Number}

Saves user currency in cart, to be paired with order/setCurrencyExchange

Source:
Parameters:
Name Type Attributes Description
cartId String

cartId to apply setUserCurrency

cartToken String <optional>

Token for cart, if it's anonymous

userCurrency String

userCurrency to set to cart

Returns:

update result

Type
Number

(static) cart/unsetAddresses(cartId, cartTokenopt, addressId, typeopt) → {Number|Object|Boolean}

Removes address from cart.

Source:
Since:
  • 0.10.1
To Do:
  • Check if no more address in cart as shipping, we should reset `cartWorkflow` to second step
Parameters:
Name Type Attributes Description
cartId String

Cart ID

cartToken String <optional>

Cart token, if anonymous

addressId String

address._id

type String <optional>

billing default or shipping default

Returns:

The number of removed documents or error object or false if we don't need to update cart

Type
Number | Object | Boolean