With the Cart API, Rokt partners can add additional products to a customer's cart within a transaction. The Cart API works with the Web SDK to help render frontend placements and provide hooks to update a customer's cart. There are two integrations needed to power upsells through Rokt:
- Integrate your backend cart/checkout system with the Rokt Cart API (this documentation).
- Integrate the Web SDK into your cart frontend.
A parking spot is a good example of a Rokt add-to-cart product. For example, a ticketing partner can upsell parking spots to their customers while they are purchasing event tickets. These parking spots are sourced through a third-party parking provider.
To fulfull customer orders, partners need to integrate with the following hook and API endpoint.
- Subscribe to V2_CART_ITEM_UPDATED events to be informed of when a user adds items to their cart.
- Call /cart/confirm to confirm the successful purchase of the items.
Some items needs to be reserved during checkout to guarantee that the inventory is still available when they eventually confirm. The following endpoints should be used for handling reservation.
- Call /cart/reserve to reserve the items for a set period of time.
- Optionally, call /cart/release to cancel a reservation and allow other customers to reserve those items.
Canceling Confirmed Items
The following endpoint is available for canceling items after they have been confirmed.
- Call /confirmation/cancel
In-transaction request flow
To fulfill customer orders, partners need to adhere to the following transaction flow.
- (Optional) Call /placements/any to determine whether there are any placements to display, so you can skip the cross-sell/upsell stage if not there are no relevant offers.
- Based on whether /placements/any returns true or false, you can choose to show or skip the upsell page in the transaction flow. On the upsell page, you must initialize the Web SDK, which requests and displays available placements.
- Once a customer opts in, the Web SDK informs the partner's frontend by sending the V2_CART_ITEM_UPDATED message. Then the normal purchase process proceeds.
- (Optional) Call /cart/reserve to reserve the items for a set period of time during which the purchase must be completed and confirmed with Rokt.
- Once a customer pays for the items, call /cart/confirm to confirm the successful purchase of the items. Rokt then informs the relevant provider of the products for fulfillment.
- To cancel a reservation, call /cart/release. This is optional as reserved items that are not confirmed are automatically released after a timeout. This is suitable for high-traffic partners that require prompt release of reserved items.
- To cancel a confirmed item, call /confirmation/cancel. This is suitable for partners who want to cancel an item after it has been confirmed.