Solved

Product page quantity multiples

AlexB87
Excursionist
12 0 2

Hi guys,

Ive been trying to create a product page template that limits the quantity drop down to multiples of 3. For example I only want to let a customer select 3,6,9,12,15 etc, and no other numbers.

I have created a new product template, and have linked it to a new section. The page is loading as expected but the multiples requirement is NOT working as expected. Below is an extract of the coding from the section:

<div class="product-form__item product-form__item--quantity">
<label for="Quantity">{{ 'products.product.quantity' | t }}</label>
<input type="number" id="Quantity" name="quantity" value="3" min="3" step="3" class="product-form__input product-form__quantity" >
</div>

When I load the page the qty starts on 3 unit, but clicking the + or - button allows you to move 1 unit, I would like this to move 3 units.

Theme - Venture

Thank you.

Accepted Solution (1)

AnishDua
Shopify Partner
57 6 10

This is an accepted solution.

Try This

 

<select id="quantity" name="quantity">
{% for i in (1..10) %}
<option value="{{ i | times:3 }}">{{ i | times:3 }}</option>
{% endfor %}
</select>
If helpful then please Like and Accept Solution.
Email: flyhighdua@gmail.com | Skype : @anish_20079

View solution in original post

Replies 6 (6)

AnishDua
Shopify Partner
57 6 10

This is an accepted solution.

Try This

 

<select id="quantity" name="quantity">
{% for i in (1..10) %}
<option value="{{ i | times:3 }}">{{ i | times:3 }}</option>
{% endfor %}
</select>
If helpful then please Like and Accept Solution.
Email: flyhighdua@gmail.com | Skype : @anish_20079
AlexB87
Excursionist
12 0 2

This works perfectly - Thank you.

BUT when in my shopping cart I can adjust the qty by 1....How do I fix this?

AnishDua
Shopify Partner
57 6 10

Add  default 1 value before loop also if useful please like  post

<select id="quantity" name="quantity">
{% for i in (1..10) %}
<optio value="1">1</option>
<option value="{{ i | times:3 }}">{{ i | times:3 }}</option>
{% endfor %}
</select>

 

If helpful then please Like and Accept Solution.
Email: flyhighdua@gmail.com | Skype : @anish_20079
AlexB87
Excursionist
12 0 2

Still the same, see below once in the shopping cart I can increase to 4, on the product page it works perfectly.

AlexB87_0-1616063381719.png

 

AnishDua
Shopify Partner
57 6 10

Hi

Under section  there is section name cart-template.liquid add step="3"  for + and  -

Below example is for refrence

 

 

 <span class="minus">-</span>
                <input type="number"  min="0" step="3" class="quantity" >
<span class="plus">+</span>

 

 

If helpful then please Like and Accept Solution.
Email: flyhighdua@gmail.com | Skype : @anish_20079
AlexB87
Excursionist
12 0 2

Would this not affect all products?

I only want this function specifically for a single product/product template.