How to customize your checkout
This guide will help you customize your checkout by creating a fully customCartItem
component.
We’ll be creating a component from scratch that allows customers to view items in their cart, retrieve the currency and language from the session
using the useCheckoutSession
hook to properly format the currency, update quantities, and remove items using the useCheckoutAction
hook and show alerts using the useMessages
hook.

Prerequisites
- Ollie Shop SDK installed
- An Ollie Shop store
This tutorial will use the hooks available via the SDK. To learn more about them you can review the Hooks documentation. We recommended going through the quickstarter guide first.
Custom “Cart Item” Component
Folder Structure
First, We will create a new folder for our project, called
'CartItem'
. Inside this folder, let’s add the basic UI structure for our CartItem
component.Create a new file called 'index.tsx'
and add the following code:index.tsx
Add styling
Create a CSS module file named
styles.module.css
with the following styles:styles.module.css
Add Session
The first two steps were very simple. It’s a simple react component, which you could have easily created yourself with any AI Coding Agent.The fun starts now. With the component in place we need to get this component to interact with your ecommerce provider.We’ve built an SDK with some React Hooks to make this super easy.Let’s enhance our
CartItem
component to use the useCheckoutSession
hook to access session data. This will allow us to use the session’s currency and language settings.Take a look at our SDK docs for a refresher on the concepts
1
Import the useCheckoutSession hook from the Ollie SDK
Update the
'index.tsx'
file to import the useCheckoutSession
hook from the SDKindex.tsx
2
Delete the original CartItemType
Now we can delete the original
CartItemType
because the SDK already exports a typeindex.tsx
3
Update the CartItem to be of type CheckoutSession
In the
CartItem
component we’ll declare the item to be of type CheckoutSession
index.tsx
4
Format Price
To make our component prettier let’s include a function that formats the price according to the
currency
which is imported from the CheckoutSession
index.tsx
5
Update the HTML Component to use the formatPrice function
index.tsx
Add Update / Remove Actions to the Component
Now let’s add functionality to update quantities and remove items. These actions already exist in the Ollie SDK
1
Import the useCheckoutAction hook from the Ollie SDK
In the
index.tsx
file, update the import
to include theuseCheckoutAction
index.tsx
2
Include Actions
Add the action hooks for removing items and updating quantities:
index.tsx
3
Create functions that manipulate the item
Create handler functions for quantity changes and item removal:
index.tsx
4
Update the buttons in your react component
Update the button components to use these handlers:
index.tsx
Add the alerts (messages)
Let’s add feedback messages to inform users when actions succeed or fail. Here are the specific changes needed:
1
Import the useMessages hook from the Ollie SDK
First, update the imports to include
useMessages
:index.tsx
2
Include message action
Add the message hook to access the
messages
system:index.tsx
3
Include the message hook to the functions
Update the action hooks to include success and error handlers:
index.tsx
Final Code
Here’s the complete CartItem component with all features implemented: