Storefront SDK

You can use ShopBase Storefront SDK to access shop data, listen to shop events like add to cart, update cart quantity, etc.

This is list of exposed events and actions for 3rd party apps. It provides the ability to interact with shop data, functions. For example, retrieving products, collections, carts, etc.

ShopBase Storefront leverage latest technology to provide a fast shopping experience for buyers, we uses single page app stack (VueJS, VueX) on ShopBase Storefront so make sure you listen to page change events and update your apps accordingly.

Ready

Specify a function to execute when the SDK is fully loaded.

window.sbsdk.ready(function() {
    console.log('ready');
});

Get content

Get page context

window.sbsdk.page.getContext() // { type: 'product', payload: { id: 1 }}

Get current product

window.sbsdk.product.current() // { id: 1000000003239458, title: "T-shirt" }

Get cart

window.sbsdk.cart.get() // { token: '', items: [], subtotal_price: 0, total_price: 0 }

Get user

window.sbsdk.user.get() // { id: 1 }

Get order

Events

Listen page load

This event will be fired when the current page is starting to load

Listen page context update

Listen add to cart

Listen cart update

Listen remove cart item

Listen an user authorized

Listen an user unauthorized

Listen order completed

This event is fired when the current order has been completed

Actions

Add to cart

Add a product with variant id 123456 into cart.

Update cart item

Update quantity of an existing product with variant id 123456 in cart.

Update cart items

Remove cart item

Clear all items in cart

Add a discount code

Remove a discount code

Navigate to sign in

Navigate to sign up

Navigate to checkout

Last updated

Was this helpful?