Next Commerce
UpsellsReference

Events

Events emitted by the upsell enhancers. Listen with window.next.on('event', handler).


upsell:initialized

When: An offer container (data-next-upsell="offer" or data-next-upsell-selector) finishes initializing.

Payload:

FieldTypeDescription
packageIdnumberPackage ID, or 0 for selector mode
elementHTMLElementThe container element the enhancer is bound to

upsell:viewed

When: A page with <meta name="next-page-type" content="upsell"> is loaded with an order in orderStore. Tracked once per unique page path per page load.

Payload:

FieldTypeDescription
pagePathstringThe page's window.location.pathname
orderIdstringThe ref_id of the loaded order

upsell:option-selected

When: A [data-next-upsell-option] card or [data-next-upsell-select] value is changed inside an offer container.

Payload:

FieldTypeDescription
selectorIdstringThe data-next-selector-id of the container
packageIdnumberThe newly selected package's ref_id

upsell:quantity-changed

When: A [data-next-upsell-quantity="increase"|"decrease"] button is clicked or a [data-next-upsell-quantity-toggle] card is selected.

Payload:

FieldTypeDescription
selectorIdstring | undefinedThe container's data-next-selector-id, or undefined
quantitynumberThe new quantity
packageIdnumber | undefinedThe current package, if known

upsell:adding

When: An offer container's add/accept button is clicked and the API call is about to start. Emitted by data-next-upsell="offer".

Payload:

FieldTypeDescription
packageIdnumberThe package being submitted

upsell:added

When: The offer container's API call succeeds and the order is updated. Emitted by data-next-upsell="offer".

Payload:

FieldTypeDescription
packageIdnumberThe package that was added
quantitynumberNumber of units added
orderobjectThe full updated order
valuenumberPrice of the added line, including tax
willRedirectbooleantrue when a redirect URL was configured

upsell:accepted

When: A data-next-action="accept-upsell" button's API call succeeds and the order is updated. For bundle linkage, fires once per package in the bundle.

Payload:

FieldTypeDescription
packageIdnumberThe package that was added
quantitynumberNumber of units added
orderIdstring | nullThe ref_id of the updated order
valuenumberPrice of the added line, including tax. 0 if no matching upsell line was returned

upsell:skipped

When: A data-next-upsell-action="skip" (or decline) button is clicked.

Payload:

FieldTypeDescription
packageIdnumber | undefinedThe package that was skipped
orderIdstring | undefinedThe ref_id of the loaded order

upsell:error

When: The offer container's API call fails. Emitted by data-next-upsell="offer" only — the accept-upsell button rethrows the error and emits action:failed instead.

Payload:

FieldTypeDescription
packageIdnumberThe package that failed to add
errorstringThe error message

upsell-selector:item-selected

When: An option card is selected inside an offer container. Emitted alongside upsell:option-selected for cross-enhancer compatibility (this is the event the accept-upsell button listens to when it links to an offer container via data-next-selector-id).

Payload:

FieldTypeDescription
selectorIdstringThe container's data-next-selector-id
packageIdnumberThe newly selected package's ref_id

action:success / action:failed

When: Any BaseActionEnhancer action completes. The accept-upsell button is a BaseActionEnhancer, so it emits these alongside upsell:accepted.

Payload:

FieldTypeDescription
actionstringClass name of the enhancer (AcceptUpsellEnhancer)
data.elementHTMLElementThe button element
error (failed only)ErrorThe error that was thrown

Listening to Events

window.nextReady.push(() => {
  window.next.on('upsell:accepted', ({ packageId, value, orderId }) => {
    console.log(`Upsell ${packageId} accepted for ${value} on order ${orderId}`);
  });

  window.next.on('upsell:skipped', ({ packageId }) => {
    console.log(`Upsell ${packageId} skipped`);
  });
});

On this page