Articles on: CornerCart

How to use Web SDK?

Our Web SDK lets you control the Cart Widget from your JavaScript code. This lets you listen to various events, as well as open, close the or do fancy stuff with the it. This guide helps you use Web SDK from your code.

Available Functions


Web SDK lets you do actions on the Corner cart. You have the following actions available (as JavaScript functions):

Event Listener Function


These following functions listens for a particular action in our widgets and when that happens the call back function you define will be executed

corner.on(eventName,callback)

EventNames

onCartEdit : When any type of edit happens on the cart
onCowiOpen : When cart widget is opened
onCowiClose : When cart widget is closed
onSatcAppear : When Sticky add to cart bar appears
onSatcDisappear : When Sticky add to cart bar disappears
onCartCtaClick : When CTA button on the cart is clicked
onSatcCtaClick : When CTA button on the Sticky add to cart is clicked

Example
The following function will print a message to the browser console every time some edit happens to the cart
corner.on("onCartEdit",()=>{console.log("Cart Edited")})


Information Fetch Function


These following function fetch certain informations from our end.

corner.get(infoName)

infoNames

cartInfo : Get cart object which includes information regarding your current cart
currentProduct : Get product object of the current product that your are in
pageType : Get the type of the page that you in

Example
The following function will assign the current page type to a variable named a
let a = corner.get("pageType")


Action Function


These functions lets you do something on the cart widget. Like opening and closing the widget

corner.do(actionName,value)


Open cart widget


Run the following code to open the cart
corner.do("openCart")


Close cart widget


Run the following code to close the cart
corner.do("closeCart")


Open the item adder popup


When you run the following javascript function, the cart widget will open up on top of that an option to add a certain item to the cart will also popup.
You should pass the product handle of the certain product you want to show as popup, as the second argument of the function.

corner.do("cartAdder",productHandle)


For Example

The following function will open the cart and inside the cart widget the visitor will be given an option to add the the product "logitech-m350" to his cart.
corner.do("cartAdder","logitech-m350")


Updated on: 09/03/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!