Web Integration Methods and Events

Here is a list of every methods end events that you can use when you implement a widget on your page.

πŸ“˜

Global variable

When you integrate a widget to your page, it will automatically add a global variable JoinStories. It is useful if you need to interact with the Widget. See below for available methods.

Methods

Close Player

Close the player if the player is open.

window.JoinStories.closePlayer(alias?: string): void {};

Arguments

  • alias(optional): the alias of the widget you want to close the player from. If not specified, it will close any JOIN players opened.

Resolve add-to-cart order

Method to resolve an add to cart order. After receiving an JOIN_STORIES_ADD_TO_CART event, you should call this method once the product is added to cart. For more information on this method usage, look at this guide.

window.JoinStories.resolveAddToCart(orderId: string, error = false : boolean | AddToCartError): void {};

Arguments :

  • orderId : the orderId received in the JOIN_STORIES_ADD_TO_CART event.
  • error(optional) : If you could not add the product to the cart, send an error code link to your error, or send true if their is no generic error for this case. If not provided of false, add to cart is considered a success.
    Generic errors :
    • PRODUCT_OUT_OF_STOCK : the product is no longer available.


Events

Add to cart Requested

JOIN_STORIES_ADD_TO_CART : The user is trying to add a product to the cart. When you receive this event, you should confirm if the add to cart is a success or not using the resolveAddToCart method. For more information on this event usage, look at this guide.

Events details

  • widgetAlias : the alias of the widget used to add to cart.
  • orderId : a unique id used to resolve the order.
  • productId : the ID of the product the user wants to add to cart.
  • variantId(optional): the ID of the variant of the product the user wants to add to cart, if there is a variant.
  • price : the price at which the product is in the story.
  • currency: the currency used for the price.
  • quantity : the quantity the user is trying to purchase.

See Cart Requested

JOIN_STORIES_SEE_CART : The user is trying to add a product to the cart. For more information on this event usage, look at this guide.

Events details

  • widgetAlias : the alias of the widget used to add to cart.