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 (Web SDK documentation).
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.
In-transaction request flow
To fulfill customer orders, partners need to adhere to the following transaction flow.
- Call /placements/any to determine whether there are any placements to display, so you can skip the 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 calling updateItemCallback. Then the normal purchase process proceeds.
- Call /cart/reserve to reserve the items for a set period of time during which the purchase must be completed and confirmed with Rokt. If multiple cart items are passed into this method, some of them might be reserved successfully, and some might be rejected.
- 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 hihg-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.