Add to cart form

product-customizer-add-to-cart-form-handlers-setup

Triggered after setting product customizer's own form handlers - handle file uploads, enforce required fields, set up option pricing.

Origin element (target)

'.product-customizer-options'

Handler arguments

⚔️ None

Usage examples

Add a custom form handler.

// Must enforce required fields because bold cart keeper app bypasses browser
// built-in form validation by calling $('#AddToCart').closest('form').submit()
$('.product-customizer-options[data-product-id="{{ product.id }}"]').on(
  'product-customizer-add-to-cart-form-handlers-setup',
  function(event) {
    var productId, always;
    productId = $(event.target).data('productId');
    if (!productId) {
        return; // There is no product id. Don't just do something, sit there! :P
    }
    shopstorm.apps.productCustomizer.options.enforceRequiredFields(productId, always = true)
  }
);

product-customizer-unbind-product-form-handlers

Triggered after unbinding (removing) product form event handlers.

Origin element (target)

'.product-customizer-options'

Handler arguments

⚔️ None

Usage examples

Add our own custom product form handler after others are removed.

$('.product-customizer-options').on(
  'product-customizer-unbind-product-form-handlers',
  function(event) {
    $(this).closest('form[action="/cart/add"], form[action^="/cart/add"]').on('submit', function() {
      console.log('Custom form event handler fired. Form is: ', this);
    });
  }
);

Still need help? Contact Us Contact Us