shipped-suite-shopify-headless-client-sdk
v1.1.3
Published
1. Install shipped-suite-shopify-headless-client-sdk
Readme
shipped-suite-shopify-headless-client-sdk
- Install shipped-suite-shopify-headless-client-sdk
npm i shipped-suite-shopify-headless-client-sdk- Add the
divsnippet where you would like the widget to appear in the cart or checkout flow.
<div class="shipped-widget"></div>- Import the Shipped Controller
import { Controller } from 'shipped-suite-shopify-headless-client-sdk'- Instantiate the JS SDK
const shippedController = new Controller({
widgetSelector: '.shipped-widget',
})- Listen and react to
onInitandonChange.onInitis triggered only once when the widget is initialized. When a user opts in or opts out of Shipped Widget, or when the offer changes,onChangecallback is triggered. Your code should provide a handler for this callback, and ensure any necessary processing required by your backend server. For example:
shippedController.onChange(details => {
// Example 'details':
// {
// "isSelected": true,
// "totalFee": "2.23",
// "shippedProducts": []
// }
})- When the cart changes, for example products are added or removed, product quantity is changed, you need to trigger update method. The widget will update its state and price offer based on the new cart total.
shippedController.update()