APIs
Leverage our public APIs
Smootify is JS dev friendly! It exposes many APIs that you can use to further customize and enrich your Webflow site!
Wait for Smootify
The Smootify instance is exposed only after the APIs are loaded, so be sure to wrap all your code inside the API Loaded callback, e.g:
If you don't want to care about using callbacks and you are hosting your scripts elsewhere and not inline you can add a script with type smootify-load
, it will be loaded after APIs are available. The type of the module will be set based on the data-type attribute you add to the script or will be set as application/js
by default.
Shopify Files
You can also upload js files to Shopify > Content > Files and use that as CDN if you need 😉
Query
It allows you to access the whole storefront graphql api without thinking about any fetch call, tokens and all the rest
Syntax
Parameters
Prop | Type | Default |
---|---|---|
query | string | - |
variables? | Record<string,any> | {} |
Examples
Query Customer
It allows you to query customer fields for the current logged in customer, it can automatically fetch either from the old or new customers account APIs based on if you are using passwordless login or not. This is not the full Customer Accounts Api but is limited to only query the Customer object, schemas below:
Handle Errors
If the customer is not logged in it will throw up an error, so handle it in your custom code
Syntax
Parameters
Prop | Type | Default |
---|---|---|
fields | string | - |
Examples
Set Customer Metafields
It allows you to set customer fields for the current logged in customer. Be sure to set the metafields as readable/writable from Customer Accounts API
Handle Errors
If the customer is not logged in it will throw up an error, so handle it in your custom code
Not for Legacy
This method will not be available if you are using legacy accounts.
Syntax
Parameters
Prop | Type | Default |
---|---|---|
metafields | Object | - |
Examples
Apply Coupon Code
It allows to apply a coupon code to the cart without user interaction, usefull if you want to add a specific coupon code based on your js interactions
Syntax
Parameters
Prop | Type | Default |
---|---|---|
couponCode | string | - |
Examples
Change Market By Country ISO Code
It allows to change up the market by an ISO code, usefull if you want to use some ip localization or select the market manually
Syntax
Parameters
Prop | Type | Default |
---|---|---|
isoCode | string | - |
Examples
Change Market Language
It allows to change up the market language, usefull if you want to use some ip localization or select the market language manually
Syntax
Parameters
Prop | Type | Default |
---|---|---|
isoCode | string | - |
Examples
Add to Cart
It allows to add lines to the cart and refresh the cart render automatically, you can also optionally redirect directly to the Checkout
Syntax
Parameters
Examples
Get Cart ID
It allows to get the current cart ID, usefull if you want to directly mutate the cart state using your own queries
Syntax
Examples
Reload Cart
It allows to re-render the cart, usefull if you modified the cart state using your own queries
Syntax
Clear Cart
It allows to remove all items from the cart
Syntax
Format Money
It formats a string (cents) or a number as a money string based on the Shopify format
Syntax
Parameters
Prop | Type | Default |
---|---|---|
cents | string | number | - |
Examples
Add Box to Cart
This function allows you to add a group of products as a box.
It requires Magic Box Add-on enabled