-
Create a snippet called 'bundled.liquid' and paste the code from the file below.
-
Open theme.liquid and add
{% include 'bundled' %}
to the bottom of the file, just above where it says</body>
. -
Find out where variant changes happen. This is different depending on the theme. Some themes are documented below.
Places to check:
- sections/product-template.liquid
- assets/themes.js
- If your theme uses optionSelectors:
Search for code like this:
var selectCallback = function(variant, selector) {
if (variant && variant.available) {
// existing code here
}
}
Replace it with this:
var selectCallback = function(variant, selector) {
bundled(variant, function(bundle) {
if (variant && variant.available && bundle.available) {
// existing code here
}
})
// use bundle.quantity to limit max quantity that can be ordered - e.g. $('#quantity').attr('max', bundle.quantity);
}
Note: Some themes bypass the selectCallback if there is only 1 variant. You will see code like this:
{% if product.variants.size > 1 or product.options.size > 1 %}
new Shopify.OptionSelectors...
{% endif %>
Change it so that the select callback is called:
{% if product.variants.size > 1 or product.options.size > 1 %}
new Shopify.OptionSelectors...
{% else %}
selectCallback({{ product.first_available_variant | json }}, {product: {id: {{ product.id }}}})
{% endif %>
Note:
- This code will not work on collection pages (i.e. in 'Quick View' forms).
Contact us for a quote if you need help with installing this script.