Cart Selectors
- getCartItems
- getCartItemById
- getCartProducts
- getCartCoupons
- getCartProductCount
- getProductPendingCount
- getCartProductDisplayCount
- getOrderableStatus
- getCurrency
- getSubTotal
- getShippingCosts
- getCartMessages
- getFlags
- getAddToCartOptions
- getAddToCartMetadata
- hasCouponSupport
- getIsFetching
getCartItems
Retrieves all cart items from the cart data in the store.
Usage
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
state
(Object) required: The application state.
Returns
(Array): The cart items as an array. If no items are found, it returns an empty array.
Cart items will match the
cartItems
from the getCart pipeline response.
getCartItemById
Retrieves a cart item from the cart data in the store by the item’s ID.
Usage
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
state
(Object) required: The application state.props
(Object) required: An object containing props.cartItemId
(string) required
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
cartItems
from the getCart pipeline response.
getCartProducts
Retrieves all cart items from the cart data in the store that are of type product
.
Usage
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
state
(Object) required: The application state.
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
Retrieves all cart items from the cart data in the store that are of the type coupon
.
Usage
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
state
(Object) required: The application state.
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
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.
Usage
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
state
(Object) required: The application state.
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
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.
Usage
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
state
(Object) required: The application state.
Returns
(number): The current pending product count. It returns 0
by default.
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.
Usage
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
state
(Object) required: The application state.
Returns
(number): The current number of products in the cart data of the store.
getOrderableStatus
Retrieves the current isOrderable
status from the cart data in the store.
Usage
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
state
(Object) required: The application state.
Returns
(boolean): Whether the cart is orderable.
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.
Usage
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
state
(Object) required: The application state.
Returns
(string): The currency code. Examples include USD
or EUR
.
getSubTotal
Retrieves the subtotal before shipping costs from the cart data in the store.
Usage
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
state
(Object) required: The application state.
Returns
(number): The subtotal as a float number.
getShippingCosts
Retrieves the total shipping costs from the cart data in the store.
Usage
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
state
(Object) required: The application state.
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
Retrieves all messages that are present in the cart data in the store.
Usage
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
state
(Object) required: The application state.
Returns
(Array): An array of messages. If no messages are set, it returns an empty array.
getFlags
Retrieves additional information about the cart from the cart data in the store.
Usage
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
state
(Object) required: The application state.
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
Builds the data for the options
property in the addProducts pipeline
request payload.
Usage
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
state
(Object) required: The application state.props
(Object) required: An object containing props.options
(Object) required: The product options.
Returns
(Object|null): The options for the pipeline request.
getAddToCartMetadata
Builds the data for the metadata
property in the addProducts pipeline
request payload.
Usage
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
state
(Object) required: The application state.
Returns
(Object|null): The metadata object for the pipeline request.
hasCouponSupport
Checks if the cart supports redemption of coupons.
Usage
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
state
(Object) required: The application state.
Returns
(boolean): Whether the coupons feature is enabled.
getIsFetching
Checks if the cart is currently fetching fresh data.
Usage
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
state
(Object) required: The application state.
Returns
(boolean): Whether the cart is fetching.