PreProduct can add extra Shopify line item properties to your cart and resulting orders. This works for both mixed and isolated redirects.
Adding custom line item properties to pre-orders #
To add custom properties, set the ppCustomLineItemProperties variable on the window object. This must be a JavaScript object. Here’s how:
Setting additional Shopify line item propertieswindow.ppCustomLineItemProperties = { "preorders_are": `great` }
Adding line item properties from customer input #
Sometimes Shopify product pages have form fields for the customer to fill in which are submitted as line item properties. Below is a snippet that you can copy and paste into your theme’s product page to include these on pre-orders.
<script>
window.addEventListener('ppCartSessionTransactionReady', (e) => {
const inputs = document.querySelectorAll('input[name*="properties"]');
inputs.forEach((input) => {
const name = input.name.replace("properties[", "").replace("]", "")
e.detail.itemAddition.properties[name] = input.value;
});
});
</script>