Shopping with StorifyMe
In case you want your Stories and Shorts to work as a Shopping point, this is possible with StorifyMe Shopping integration and StorifyMe Cart
.
StorifyMe Web SDK provides a set of methods and events to manage and interact with the shopping cart within your application.
Methods
Get cart
This method retrieves the current state of the shopping cart and can be used as:
const cartItems = widget.shopping.cart.get();
Clear cart
This method removes all items from the cart and can be used as:
widget.shopping.cart.clear();
console.log('Cart has been cleared.');
Events
You can attach and subscribe to events in order to run logic on your website when something happens in Stories and Shorts regarding Shopping logic.
In order to be sure that you will receive all the events, eg. onLoad
, please first register events and then initialize the widget.
You can mark the widget to be manually loaded with init="manual"
.
onShopping()
onShopping
method is invoked every time some cart manipulation is happening.
Supported types:
- CART_UPDATED - Happens every time cart is changed
- CART_ITEM_ADDED - Happens when a product is added to cart
- CART_ITEM_REMOVED - Happens when a product is removed from the cart
- CHECKOUT - Happens when user clicks on Checkout button in cart
// Get the widget element
const widget = document.querySelector('#widget');
widget.addEventListener('onShopping', (event) => {
console.log(event.type); // Type of the shopping action that happened
console.log(event.detail); // Details for the action that happened
});
// Load widget
widget.load();