The Checkout SDK is a JavaScript library of methods for performing actions related to checkout. It includes methods for logging in a customer, adding addresses to the checkout object, and surfacing the shipping and payment methods a merchant configures. It’s everything you need to build your own custom checkout page on BigCommerce.
Our reference implementation is a great place to start if you prefer to develop within a framework. However, the SDK, built with vanilla JavaScript, is framework-agnostic.
This article will walk you through becoming familiar with Checkout SDK and experimenting with building checkouts using Cornerstone. At the end of the article, you will have installed the Checkout SDK, created a new JavaScript module for your custom checkout, and console-logged the checkout object.
For example, cd cornerstone
templates/pages/checkout.html right after {{#partial “page”}}.templates/pages/checkout.html.initSdk() is in charge of loading checkout-sdk, creating the service, and loading checkout with our current cart/checkout id.
checkout.content_head contains information for rendering the template to initialize a checkout-js React app.
The checkout.html page should look like this:
In the developer console, you can see the entire available cart object. The output will look like this:
We can, for example, get or set shipping and billing addresses, sign in customers, apply coupons or gift certificates, initialize payment, or complete orders.
How can I find the Checkout SDK version my custom checkout is currently using?
The Checkout SDK version is included in all API request headers from the checkout.
To find your version:
x-checkout-sdk-version.