Demo index

Pre-order javascript events

PreProduct provides custom Javascript events that let you run front-end code for pre-order products. Here's a guide for the available events.

2 min read

Still stuck?

Ask the docs AI anything, or talk to the team. We usually reply within a few hours.

Contact us
Launch Event

Fires once PreProduct initializes on product pages (if the product is on pre-order). Use the Cart Session events if you need events capable of firing on every page.

javascript
window.addEventListener('ppJustLaunched', () => {
   //do something good here
}, false)
Button Click Event

Fires when the pre-order button is clicked:

javascript
window.addEventListener('ppConvertingButtonClicked', () => {
   //do something great here
}, false);
Conversion Event

Fires after adding a pre-order item to cart/checkout:

javascript
window.addEventListener('ppJustConverted', () => {
   //do something even greater here
}, false)
Event Details

All of the above events provide data in the below format. The items value follows the Shopify AJAX API format.

javascript
 {
	"id": 23334, // PreProduct internal ID
 	"productId": 4593157046349, // Shopify product REST ID
 	"items": // AJAX '/cart/add.js' payload
 		[
 			{
 				"id": "32316569321549"
 				"properties": {
	 				"Estimated shipping": '214 days',
	 				"_preorder": 'true' // hidden pre-order marker, always present
 				}
 				"quantity": "1"
 				"selling_plan": "1984823373"
 			}
 		]
 	}
}

Stopping PreProduct Mid-Flow


To interrupt PreProduct during a pre-order addition, you can listen for one of the custom events and then set the event.detail.handled value to true.

javascript
window.addEventListener(`ppJustConverted`, (e) => {
    e.detail.handled = true;
    console.log("PreProduct stopped after adding to cart")
})

Screen walkthroughs

Pre-sell With PreProduct

7 day free trial with all plansMigrate pre-orders