Home Javascript SDK Rest API/SSO Webhooks AppMarket Login

Javascipt SDK

Global PUBSUB events

to use JS currect on your site. you must use pubsub.
ccpubsub

ccpubsub.ready event

fired when all relevant scripts are loaded.
ccpubsub.subscribe("ready", function(){ // .. your code here })

ccpubsub.pageview event

fired when user view a page
ccpubsub.subscribe("pageview", function(){ // .. your code here })

ccpubsub.cart_add event

fired when user add an item to the shopping cart.
recieved parameters: pid - product id, qty, price
ccpubsub.subscribe("cart_add", function(event_name, data){ // .. your code here // event_name = "cart_add" // data.internalsource - upsale or default // data.pid = item id // data.price = price // data.qty = selected qty })

ccpubsub.cart_remove event

fired when user clicks on add to cart button.
recieved parameters: pid - product id
ccpubsub.subscribe("cart_remove", function(pid){ // .. your code here })

ccpubsub.cart_updated event

fired when cart is changed.
recieved parameters: {data}
ccpubsub.subscribe("cart_updated", function(pid){ // .. your code here })

ccpubsub.paybutton_click event

fired when user clicks on add to cart button.
recieved parameters: cart object
ccpubsub.subscribe("paybutton_click", function(cart){ // .. your code here })

ccpubsub.more_items_click_loaded event

fired when user clicks on load more items.
recieved parameters: State, data, page, tags
ccpubsub.subscribe("more_items_click_loaded", function(state,data,page,tags){ // .. your code here })



Checkout PUBSUB events

ccpubsub.checkout_ready event

fired when checkout page is loaded.
recieved parameters: cart object
ccpubsub.subscribe("checkout_ready", function(cart){ // .. your code here })

ccpubsub.cart_calculate_price event

fired when user change settings on checkout page (like: shipping, payment method..).
recieved parameters: cart object
ccpubsub.subscribe("cart_calculate_price", function(cart){ // .. your code here })

ccpubsub.order_completed event

fired when user complete an order.
recieved parameters: cart object
ccpubsub.subscribe("order_completed", function(event_name, data){ // .. your code here // data.order_id // data.total_price // products = products array })

In-Page JSON structure

order completed page

this JSON script tag available on order complete page:
<id="order_data" type="application/json"> { "id":"1122", "total_price":"10", "order_status":"1" , "products" : [{ "name":"product 1", "id":"23456", "price":"10", "category":"shirts", "quantity":"1" }] } </script>