◼️
Infinite Options Docs
  • Getting Started
    • How to Install
    • Create custom options
    • Show options on a product
    • Expert Install Service
  • Set up and manage options
    • Assign Options by Tag
    • Assigning Options: Excluding a few products
    • Don't display options on certain products
    • Duplicate option sets
    • Bulk Add Values to Infinite Options
    • Reorder Option Sets
    • Make drop-downs required
    • Make Swatches required
    • Change where options display
    • Finding options on the admin side
    • Featured Product/Homepage
  • Install Infinite Options
    • Boundless Theme
    • Brooklyn theme
    • Colorblock Theme
    • Craft Theme
    • Crave Theme
    • Debut Theme
    • Dawn Theme
    • Minimal Theme
    • Origin Theme
    • Publisher Theme
    • Refresh Theme
    • Ride Theme
    • Sense Theme
    • Simple Theme
    • Studio Theme
    • Supply Theme
    • Taste Theme
    • Venture Theme
    • Locating the Product Form
    • Copy of Installing Infinite Options directly in the theme (1.0 theme)
  • Add a ShopPad team member to your store
  • Increase the Cost of an Option
    • Moving from Legacy to Native Bundling
    • Show price changes on the product page
    • Native Bundling
    • Product bundles
  • Conditional Logic
    • Conditional Logic
    • Uploadery
    • Dropdown menus
    • Swatches
  • Popular Setups
    • Up-charge Pricing + Text Box
    • Mix & Match Variety Pack or Gift Pack Example
    • Add on Gift Wrapping Option
    • Multiple Engraving Initials
  • Troubleshooting
    • Resolving "Cannot Find Variant" Error
    • Cancel your Subscription
    • Is the app installed?
    • How to disable Infinite Options
    • Quick Shop Feature
    • My options are not showing
    • Performance and Optimization
      • Remove loading delays
      • Bulk Add Values to Infinite Options
      • Hide _io_order_group and _io_parent_order_group from cart
      • Display option selections on customer account page
    • Why are option selections labeled "infinite_options_1"?
    • Options are showing on desktop and not mobile
    • Dashboard terms explained
    • Options are not showing on the backend
    • Display option selections in the cart page
  • Inputs and Field Settings
    • Swatches
      • Create Swatches
      • How to make Swatches required
      • Customize Swatches using CSS
      • Adjust Swatches - display the name once the swatch is hovered over
    • Change or translate required pop-up message/characters remaining text
    • Add a date picker to your store
      • Customize the date picker
  • Visual Changes - adding styling
    • Customize Options using CSS
    • Craft theme
    • Dawn theme
    • Debut theme
    • Studio theme
  • Display Options on Shopify Notifications
    • Shopify emails and packing slip templates
      • Order Confirmation
      • Packing Slip
      • Shipping Confirmation
      • New Order
      • Fulfillment Request
      • Abandoned Checkout
    • Order Printer/Pro templates
    • Legacy: Display Options on Shopify Notifications
      • Order Confirmation
      • Packing Slip
      • Shipping Confirmation
      • New Order
      • Fulfillment Request
      • Abandoned Checkout
  • Developer Resources
    • Event API
    • Development Store/Affiliate Store Plans
  • Integrations
    • Fablet store
    • Ecomposer
    • GemPages
    • PageFly
    • Replo Page Builder
    • UpOrder
    • Weglot
    • Zipify Pages
  • FAQs & How-tos
    • Can I export options with orders via a CSV file?
    • How do I create more than 100 variants?
Powered by GitBook
On this page
  • Subscribing to events
  • Events
  1. Developer Resources

Event API

Infinite Options' Event API allows developers to tie in to and react to different processes that occur within Infinite Options. This article contains information on how to subscribe to certain actions, as well some context on what you can do with these events.

Note: This includes technical information. Knowledge of the JavaScript language is required.

Subscribing to events

Events are subscribed to by calling the subscribe method before the app has ran. The subscribe method takes two arguments, a string matching the name of the event (events are listed below), and a callback function that takes a single argument, event. In order to access this method, you will need to tie into the beforeReady callback. Here's an example of this:

<script>
  // Create "window.Shoppad.apps.infiniteoptions" object if it doesn't already exist
  "Shoppad.apps.infiniteoptions".split(".").reduce(function(o, x) { if (!o[x]) {o[x] ={};} return o[x] }, window);

  // Define beforeReady callback
  window.Shoppad.apps.infiniteoptions.beforeReady = function(subscribe) {
    subscribe('appLoad', function(event) {
      console.log('appLoad', event);
    });
  };
</script>

Note: You will need to define the beforeReady callback before the app has loaded. If you are explicitly loading the script using the instructions found in this article, you will need to define the callback before that script is called. If you aren't explicitly loading the app, defining the callback anywhere in the <head /> will suffice.

Events

Here's a list of all the available events.

appLoad

Fired when all fields have been added to the DOM and the app has run its initial processing.

/**
 * @param {object} event
 * @param {array} event.detail.fields An array of arrays, with each array being an option set that applies to the current product.
 * @param {boolean} event.detail.hasConditionalLogic True if conditional logic is active on this product, false if not.
 * @param {boolean} event.detail.hasBundledProducts True if the initial state of app has product bundles attached.
 */
subscribe('appLoad', function(event) {
  console.log('appLoad', event);
});

fieldLoad

Fired every time a field is added to the DOM.

/**
 * @param {object} event
 * @param {string} event.detail.name The field name of the input.
 * @param {string} event.detail.value The value of the input.
 * @param {object} event.detail.element A jQuery object representing the element that added to the DOM (this is the parent <div> that wraps the input and label).
 * @param {object} event.detail.fieldConfig 
 * @param {boolean} event.detail.hasConditionalLogic True if the field utilizes conditional logic.
 * @param {boolean} event.detail.hasBundledProducts True if the field has product bundles attached in its initial state.
 */
subscribe('fieldLoad', function(event) {
  console.log('fieldLoad', event);
});

fieldChange

Fired every time a field is changed. To be specific, this is fired when the native change event is fired for select menus, checkboxes, radio button, and when the keyup / touchend event is fired for text areas, text inputs, and number inputs.

/** 
 * @param {object} event
 * @param {string} event.detail.name The field name of the input.
 * @param {string} event.detail.value The value of the input.
 * @param {object} event.detail.element A jQuery object representing the element that added to the DOM (this is the parent <div> that wraps the input and label).
 */
subscribe('fieldChange', function(event) {
  console.log('fieldChange', event);
});

productBundleAdd

Fired when a product bundle is selected (can occur on page load).

/**
 * @param {object} event
 * @param {string} event.detail.name The field name of the input.
 * @param {object} event.detail.element A jQuery object representing the element that added to the DOM (this is the parent <div> that wraps the input and label).
 * @param {object} event.detail.productBundle Details about the bundled product.
 */
subscribe('productBundleAdd', function(event) {
  console.log('productBundleAdd', event);

  // Note: The product variant price returned is cached. You may want to retrieve the latest price.
  window.Shoppad.apps.infiniteoptions.getLatestVariantPrice(event.detail.productBundle, function(productBundle) {
    console.log('Latest productBundle price', event);
  });
});

productBundleRemove

Fired when a product bundle is unselected (can occur on page load).

/**
 * @param {object} event
 * @param {string} event.detail.name The field name of the input.
 * @param {object} event.detail.element A jQuery object representing the element that added to the DOM (this is the parent <div> that wraps the input and label).
 * @param {object} event.detail.productBundle Details about the bundled product.
 */
subscribe('productBundleRemove', function(event) {
  console.log('productBundleRemove', event);

  // Note: The product variant price returned is cached. You may want to retrieve the latest price.
  window.Shoppad.apps.infiniteoptions.getLatestVariantPrice(event.detail.productBundle, function(productBundle) {
    console.log('Latest productBundle price', event);
  });
});

fieldShow

Fired every time a field is shown.

/**
 * @param {object} event
 * @param {string} event.detail.name The field name of the input.
 * @param {string} event.detail.value The value of the input.
 * @param {object} event.detail.element A jQuery object representing the element that added to the DOM (this is the parent <div> that wraps the input and label).
 */
subscribe('fieldShow', function(event) {
  console.log('fieldShow', event);
});

fieldHide

Fired every time a field is hidden (can occur on page load).

/**
 * @param {object} event
 * @param {string} event.detail.name The field name of the input.
 * @param {string} event.detail.value The value of the input.
 * @param {object} event.detail.element A jQuery object representing the element that added to the DOM (this is the parent <div> that wraps the input and label).
 */
subscribe('fieldHide', function(event) {
  console.log('fieldHide', event);
});

productBundleCartSubmit

Fired when product bundles are attached and the user submits the main product's cart.

Note: This event is cancelable. Call event.preventDefault(); to prevent the app from submitting the main product's form after product bundles have been submitted.

/**
 * @param {object} event
 * @param {array} event.detail.submittedProducts The products that were submitted to the cart.
 */
subscribe('productBundleCartSubmit', function(event) {
  console.log('productBundleCartSubmit', event);
});
			

validationSuccess

Fired when validation for fields has passed.

/**
 * @param {object} event
 */
subscribe('validationSuccess', function(event) {
  console.log('validationSuccess', event);
});
			

validationFail

Fired when validation for fields has failed.

Note: This event is cancelable. Call event.preventDefault(); to prevent an alert with the error message from showing.

/**
 * @param {object} event
 * @param {string} event.detail.error The error message for the input that failed validation first.
 * @param {object} event.detail.element A jQuery object representing the element that added to the DOM (this is the parent <div> that wraps the input and label).
 */
subscribe('validationFail', function(event) {
  console.log('validationFail', event);
});
	
PreviousDeveloper ResourcesNextDevelopment Store/Affiliate Store Plans

Last updated 18 days ago