Shopify themes, liquid, logos, and UX
To adjust the standard quantity I added the following code:
<script> {% if product.type == 'Rood' %} document.addEventListener('DOMContentLoaded', function() { try { document.querySelector('input.quantity__input').value = 6; document.querySelector('button[name="minus"]').classList.remove('disabled'); } catch {} }); {% endif %} </script>
This code gives the customer a default quantity of 6 but allows them to increase/decrease it.
Currently, this only works on the product page itself. However, we also want to have this in the quick-add modal. Where do I have to insert this code and do I have to adjust it as well?
Store link is marwijn.com password is test123
Hello@martijn18
Please Try This Javascript
<script>
document.addEventListener('DOMContentLoaded', function() {
function setDefaultQuantity() {
try {
// Adjust selectors if needed for the quick-add modal
const quantityInput = document.querySelector('input.quantity__input');
const minusButton = document.querySelector('button[name="minus"]');
if (quantityInput) {
quantityInput.value = 6;
}
if (minusButton) {
minusButton.classList.remove('disabled');
}
} catch (e) {
console.error('Error setting default quantity:', e);
}
}
// Set default quantity on the main product page
{% if product.type == 'Rood' %}
setDefaultQuantity();
{% endif %}
// Set default quantity when the quick-add modal is shown
document.addEventListener('quickAddModalShown', function() {
setDefaultQuantity();
});
});
</script>
Should I paste it next to the original code in theme.liquid?
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025