Cart Selectors
- getCartItems
- getCartItemById
- getCartProducts
- getCartCoupons
- getCartProductCount
- getProductPendingCount
- getCartProductDisplayCount
- getOrderableStatus
- getCurrency
- getSubTotal
- getShippingCosts
- getCartMessages
- getFlags
- getAddToCartOptions
- getAddToCartMetadata
- hasCouponSupport
- getIsFetching
getCartItems
Section titled “getCartItems”Retrieves all cart items from the cart data in the store.
import { getCartItems } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCartItems } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(Array): The cart items as an array. If no items are found, it returns an empty array.
Cart items will match the
cartItemsfrom the getCart pipeline response.
getCartItemById
Section titled “getCartItemById”Retrieves a cart item from the cart data in the store by the item’s ID.
import { getCartItemById } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCartItemById } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.props(Object) required: An object containing props.cartItemId(string) required
Returns
Section titled “Returns”(Object|null): The cart item. If no item is found for the provided ID, the selector returns null.
The cart item will match the
cartItemsfrom the getCart pipeline response.
getCartProducts
Section titled “getCartProducts”Retrieves all cart items from the cart data in the store that are of type product.
import { getCartProducts } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCartProducts } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(Array): An array of the products in the cart data. If no products are found, it returns an empty array .
Cart products will match the cartItems of
type“product” from the getCart pipeline response.
getCartCoupons
Section titled “getCartCoupons”Retrieves all cart items from the cart data in the store that are of the type coupon.
import { getCartCoupons } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCartCoupons } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(Array): An array of the coupons in the cart. If no coupons are found, it returns an empty array.
Cart coupons will match the cartItems of
type“coupon” from the getCart pipeline response.
getCartProductCount
Section titled “getCartProductCount”Retrieves the number of products from the cart data in the store. This number is synchronized with the backend and reflects the actual number of products in the cart.
import { getCartProductCount } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCartProductCount } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(number): The current amount of products in the cart. If there are no products, it returns 0. Important: getCartProductCount does not include the coupons.
getProductPendingCount
Section titled “getProductPendingCount”Retrieves the number of products from the cart data in the store that are only in the frontend and have not yet synchronized with the backend.
import { getProductPendingCount } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getProductPendingCount } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(number): The current pending product count. It returns 0 by default.
getCartProductDisplayCount
Section titled “getCartProductDisplayCount”Retrieves the full number of products from the cart data in the store. It combines the product count and the pending product count. This number is equal to the product count when newly added products are synchronized with the backend.
import { getCartProductDisplayCount } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCartProductDisplayCount } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(number): The current number of products in the cart data of the store.
getOrderableStatus
Section titled “getOrderableStatus”Retrieves the current isOrderable status from the cart data in the store.
import { getOrderableStatus } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getOrderableStatus } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(boolean): Whether the cart is orderable.
getCurrency
Section titled “getCurrency”The cart data that is received from the getCart pipeline contains information about the currency used for the current cart. This selector retrieves the currency code from that cart data in the store.
import { getOrderableStatus } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getOrderableStatus } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(string): The currency code. Examples include USD or EUR.
getSubTotal
Section titled “getSubTotal”Retrieves the subtotal before shipping costs from the cart data in the store.
import { getSubTotal } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getSubTotal } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(number): The subtotal as a float number.
getShippingCosts
Section titled “getShippingCosts”Retrieves the total shipping costs from the cart data in the store.
import { getShippingCosts } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getShippingCosts } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(number|null): The shipping costs as a float number. It returns 0 on free shipping, and null if no shipping costs are found.
getCartMessages
Section titled “getCartMessages”Retrieves all messages that are present in the cart data in the store.
import { getCartMessages } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCartMessages } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(Array): An array of messages. If no messages are set, it returns an empty array.
getFlags
Section titled “getFlags”Retrieves additional information about the cart from the cart data in the store.
import { getFlags } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getFlags } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(Object): The cart flags.
taxIncluded(boolean): Whether the cart shows gross or net prices.orderable(boolean): Whether the cart is orderable.coupons(boolean): Whether the cart can have coupons.
getAddToCartOptions
Section titled “getAddToCartOptions”Builds the data for the options property in the addProducts pipeline request payload.
import { getAddToCartOptions } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getAddToCartOptions } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.props(Object) required: An object containing props.options(Object) required: The product options.
Returns
Section titled “Returns”(Object|null): The options for the pipeline request.
getAddToCartMetadata
Section titled “getAddToCartMetadata”Builds the data for the metadata property in the addProducts pipeline request payload.
import { getAddToCartMetadata } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getAddToCartMetadata } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(Object|null): The metadata object for the pipeline request.
hasCouponSupport
Section titled “hasCouponSupport”Checks if the cart supports redemption of coupons.
import { hasCouponSupport } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { hasCouponSupport } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(boolean): Whether the coupons feature is enabled.
getIsFetching
Section titled “getIsFetching”Checks if the cart is currently fetching fresh data.
import { getIsFetching } from '@shopgate/engage/cart';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getIsFetching } from '@shopgate/pwa-common-commerce/cart'
Parameters
Section titled “Parameters”state(Object) required: The application state.
Returns
Section titled “Returns”(boolean): Whether the cart is fetching.

