Chord OMS
...
Gatsby
SDK Reference

useCart

13min

The useCart hook returns a series of methods for interacting with the Shopify shopping cart.

JS


cart

Represents the current shopping cart.

Example:

JS


addPromoCode()

Applies a promo code to the current order.

Example:

JS


addToCart()

Adds an item to the current order.

Example:

JS


applyGiftCard()

Applies a gift card to the current order.

Example:

JS


checkout()

Redirects the browser to Shopify checkout.

Example:

JS


loadCart()

Reloads the current shopping cart. This is automatically called on every page load and with every other useCart method.

Example:

JS


modifyQuantity()

Updates the quantity of a line item in the current order.

Example:

JS


modifyLineItem()

Updates a line item in the current order.

Example:

JS


removeFromCart()

Removes a line item from the current order.

Example:

JS


removeGiftCard()

Removes a gift card from the current order.

Example:

JS


removePromoCode()

Removes a promo code from the current order.

Example:

JS






Updated 03 Mar 2023
Did this page help you?