@hadimalikdev/shopifycart v0.1.1
Table of Contents
ShopifyCart
Represents a simple Shopify cart
Uses the fetch API
Parameters
root_urlString Locale aware root URL. Most commonly accessed usingwindow.Shopify.routes.root(optional, default'/')loggingObject Set up logging (optional, default{})
addItem
Adds an item to the cart
Parameters
variant_idNumberquantityNumber? Quantity of variant to be added. (optional, default1)line_item_propertiesObject<string, string>? Key-value pairs of line item propertiesselling_planNumber? ID of selling plan
Returns Promise Returns API response
modifyCartItemByKey
Modifies quantity of a line item using line_item_key
Parameters
line_item_keyStringquantityNumber New quantityline_item_propertiesObject<string, string>? Key-value pairs of line item propertiesselling_planNumber? ID of selling plan
Returns Promise Returns API response
modifyCartItemByIndex
Modifies quantity of a line item based on 1-based index position of the item in the cart
Parameters
indexNumber 1-based index of item in cartquantityNumber Updated quantityline_item_propertiesObject<string, string>? Key-value pairs of line item propertiesselling_planNumber? ID of selling plan
Returns Promise Returns API response
modifyCartItemByID
Modifies quantity of a line item based on variant id
Parameters
variant_idString Variant ID of item in cartquantityNumber New quantity of itemline_item_propertiesObject<string, string> Properties of the cart itemselling_planNumber
Returns Promise Returns API response
getCart
Fetches cart
Returns Promise Returns API response
updateCart
Updates the cart note and attributes
Parameters
noteString Cart note. Pass undefined if want to leave as isattributesObject<string, string> Cart attributes. Pass undefined if want to leave as is
Returns Promise Returns API response
clearCart
Removes all items from cart.
Returns Promise Returns API response
generateShippingRates
Generates shipping rates Use the getShippingRates function to retrieve rates once calculations are complete
Parameters
Returns Promise Returns API response
getShippingRates
Gets shipping rates Use the generateShippingRates function to calculate the rates
Parameters
Returns Promise Returns API response