This will not change the Accessory quantity in the cart if the main product quantity is changed or removed
Overview:
You may find it necessary to set the Accessory Quantity to be the same as the main product quantity. The following article will explain how to do just that, with just a few snippets of code!
Settings:
Quantity Selector for accessories will need to be enabled. This can be found in the Settings tab of the app:
Code:
Add this script before the </head> in the theme.liquid file.
Note: You may have to replace the first two values to match your theme's classes/IDs.
<script type="text/javascript">
var qtySel = $('#quantity'); //Replace this selector with your main quantity's unique identifier
var qtyAdjustBtn = $('.js-qty__adjust'); //Replace this selector with the identifier for the buttons on your qty selector. If you do not have any, then leave it as is
var accQtySel = $('.accessoryQuantity');
var qtyVal = $(qtySel).val();
function accessoryItemAddedCallback(div, product) {
$($(div).find(accQtySel)).val(qtyVal);
}
function accessoriesDoneLoadingCallback() {
$(qtyAdjustBtn ).on('click', function() {
$(qtySel).trigger('change');
});
$(qtySel).change(function() {
$(accQtySel).val(qtyVal);
});
} </script>