Skip to content

How to add a Convermax vehicle to every product in an order

How to configure?

  • Import addVehicleToCartProduct to the config.js.

    import { addVehicleToCartProduct } from '../_common/shopifyCartProductVehicle.js';
  • Call the addVehicleToCartProduct function on an ‘Add to Cart’ event within the InitFunc function.

    const InitFunc = () => {
    window.document.body.addEventListener('on:cart:add', (e) =>
    addVehicleToCartProduct({ variantId: e.detail?.variantId, cart: e.detail?.cart }),
    );
    };

    If the store theme does not trigger an ‘Add to Cart’ event, you need to dispatch it after adding to cart from the theme code.

    window.document.body.dispatchEvent(
    new CustomEvent('on:cart:add', {
    detail: {
    // variantId: 'id of the variant that was just added to the cart',
    // cart: 'the new cart object after the variant was added (optional)',
    },
    }),
    );