Manage checkout as a shopper
4.0 Manage checkout as a shopper
The Checkout SDK and Server-to-Server (S2S) Checkout V3 APIs have been updated to support Buy Online, Pick up in Store experiences.
When building a Buy Online, Pick up in Store solution, you can allow shoppers to find available pickup options and create checkout consignments that are fulfilled by a pickup method.
As a developer, you may wonder which to choose and when to use the SDK vs the API. If you’re developing:
- A native storefront and custom checkout experience, use the Checkout SDK
- An end-to-end headless experience, use the S2S Checkout APIs
If you’re dependent on webhook events, all existing Cart webhooks have been updated to support Buy Online, Pick up in Store.
4.1 Native storefront & custom checkout experience using Checkout SDK
To support Buy Online, Pick up in Store, we would be adding a loadPickupOptions method to the CheckoutService class, allowing you to load pickup options to your storefront checkout. In order to fetch pickup options using the Checkout SDK, you will need to be on SDK version 1.224.0 or above. This applies to existing custom checkouts, as well as new custom checkouts.
You can show pickup method options to customers on a storefront page, such as the Product Detail Page, before having a consignment. For more information, see 4.2.2 Find available pickup methods with stock available.
4.2 End-to-end headless experience (S2S APIs)
4.2.1 Create a cart with a product in it
To create a cart, send a request to the Create a cart endpoint.
Request
Response
For a successfully-created cart, the response will have:
- The newly-created cart ID. In this example, the cart ID is
76f1bfe4-dbbe-4018-8ee6-2e3c36bf1518. - The physical product ID. In this example, the cart ID is
67642f07-49d1-4501-8b7d-2e589aec34b8.
Cart ID is the same as Checkout ID and both represent the same identifier for a cart depending on which API is being consumed: the Cart API uses cart ID and the Checkout API uses Checkout ID.
4.2.2 Find available pickup options with stock available
To find available pickup options, send a request to the Find available pickup options endpoint.
Request
Response
4.2.3 Create the pickup consignment for the checkout
To create the pickup consignment for the checkout, send a request to the Add consignment to checkout endpoint.
Request
Response
From the response we can see the consignment object now has a selected_pickup_option set with the pickup_method_id that you requested.
Currently, Buy Online, Pick up in Store only supports 1 consignment of type Pickup. If you attempt to mix pickup and shipping consignments or create multiple pickup consignments, you will receive an error message.
If you have a change of mind, and you want to change it from pickup to be shipped, then you will need to update the consignment. To update a consignment, send a request to the Update checkout consignment endpoint.
Request
Response
The available_shipping_options is returned if we add the include=consignments.available_shipping_options to the request.
This allows us to select a shipping option as described in the next request:
Request
Response
We can see in the response above the selected_shipping_option contains the shipping method selected, and there is no longer a pickup object.
4.2.4 Update pickup consignment in the cart/checkout
If you want to update the consignment from shipping to pickup or select another pickup method, you can edit the consignment and send a new pickup method ID. The pickup method ID is retrieved from the api call to the pickup endpoint earlier.
Request
Response
4.2.5 Finalize order creation (i.e. complete checkout by API)
To finalize an order, send a request to the Finalize an order endpoint.
Request
Response
The order ID is 126.