2 min read
Cart
The Cart is a core feature for most apps to allow the user to add items to and view their basket.
Deeplinks
# Cartcartbag
Navigating to the cart will switch to the cart tab if the cart is a tab.
Dynamic Content
Cart supports the following Dynamic Content slots:
Slot | Version | Where? |
---|---|---|
scroll-top | v25+ | Before all scroll content, not in edit mode. |
scroll-bottom | v25+ | After all scroll content, not in edit mode. |
Adding slots to a table view is less complex compared to collection views but more than stack views.
You will need to customise the data source to add custom slots and map their content to CartContentBlock.slot()
items.
Navigation
By default the Cart is presented as the middle tab but you may want to replace this with a more engaging feature such as Swipe to Like. To allow this you can configure the app to present the Cart button globally on the navigation bar.
- Open your
AppModule
to thedidAddToPlatform
orsetUpCart
functions. - Inject the
CartNavigationButton
as the app-wide navigation bar button.
Container.shared.views.navigationBarButtonItem.replace { .cart }
This button can be customised or moved anywhere within your app. See the navigation button customisation docs for further details.
Vouchers & Promotions
The Cart screen supports adding vouchers using the CartService
so long as the BE can support this.
Vouchers requires additional API to work.
To enable vouchers:
- Open your
AppModule
to thedidAddToPlatform
orsetUpCart
function. - Set the vouchers setting to true at the start of the function.
Settings.Cart.showsVouchers = true
Express Checkout Widgets
Express checkout widgets require additional API or external platform configuration to work. To add an express checkout widget:
- Open your
AppModule
to thedidAddToPlatform
orsetUpCart
function. - Inject the express checkout widgets you wish to use.
Container.shared.views.checkoutWidgets.replace {[ Container.shared.views.applePayWidget(), Container.shared.views.payPalWidget()]}
Shipment Levels
From v25, the Cart supports 2 shipment levels as part of the BOPIS work.
The .checkout
level changes the Cart and PDP Cart Widget to present shipment availability banners.
The app defaults to a BOPIS specific banner but this can be customised to present alternate shipping eligibility.
With this level the user should expect to be able to change shipment type at checkout.
The .item
level changes the Cart and PDP Cart Widget to present interactive shipment selection per item.
The user is able to switch between available shipment options which updates the PDP stock focus.
With this level the user should expect to be able to set different shipment types per cart item.
To switch shipment levels:
- Open your
AppModule
to thedidAddToPlatform
orsetUpCart
function. - Set the shipment level setting to the desired setting at the start of the function.
Settings.Cart.shipmentLevel = .checkout
Add to Cart Widget
The CartWidget
is a standalone component that can be added to any screen to allow the user to add a product to cart.
See the cart widget documentation for more information.
History
- v25: State architecture rewrite, BOPIS (shipment levels) and slots.
- v22: Added support for Cart Vouchers & Promotions.