Add Quantity Dropdown with as example 250 Pcs, 500pcs tec

Solved
LovisShop
Excursionist
32 0 2

I have this code :

 <div class="product-form__item product-form__item--quantity">
            <label for="Quantity">{{ 'products.product.quantity' | t }}</label>
           <select name="quantity" id="quantity">
         {% for i in (1..40) %}
                  <option value="{{ i }}">{{ i }}</option>

How can i do that only selected Quantitys as example 250, 500, 1000, etc. appear?

My Theme: Venture Snowboard, sectioned....

 

Thanks in advance

Lovis

VishvasMishra
Shopify Partner
202 40 46

Hi, 
You can use blocks of section to show different dropdown on different product using customization. You only have to create text field and have to put quantity separated by "," and you can call it by matching product handle then split them by comma ",". and show them in forloop.
Please let me know if you want code for this.

For Design, Development and custom changes Hire Me.
If your problem solved then Like & Accept this Solution.
Email ID: technicalvishvas@gmail.com
Ambité
Excursionist
30 1 3
@VishvasMishra,
Hey,
I am a newbie in coding so it would be nice if you could show me how its done...

Thanks so much
0 Likes
VishvasMishra
Shopify Partner
202 40 46

This is an accepted solution.

Please find input having id="Quantity"  in product-template.liquid

and replace the 
<input type="number" id="Quantity" name="quantity" value="1" min="1" class="product-form__input product-form__quantity">

by this below 

{% assign qtyarr = "" %}
{% for block in section.blocks %}
{% if product.handle == block.settings.product %}
{% assign qtyarr = block.settings.qty | split:"," %}
{% endif %}
{% endfor %}
{% if qtyarr == ""%}
<input type="number" id="Quantity" name="quantity" value="1" min="1" class="product-form__input product-form__quantity">
{% else %}
<select id="Quantity" name="quantity" >
{% for qty in qtyarr %}
<option value="{{ qty }}">{{ qty }}</option>
{% endfor %}
</select>
{% endif %}


Add the schema before last } in product-template.liquid

,
"blocks":[
{
"type":"product_qty",
"name":"Product QTY",
"settings":[
{
"type":"product",
"id":"product",
"label":"Product on which below qty visible"
},
{
"type":"text",
"id":"qty",
"label":"Quantity Seperated by Comma (,)"
}
]
}
]

the you will get the option to choose product and add qty in backend
solution.jpg

For Example see the below url  on my testshop. you will see only select option on this product as i have added for this product only
https://testvish.myshopify.com/products/chain-bracelet

For Design, Development and custom changes Hire Me.
If your problem solved then Like & Accept this Solution.
Email ID: technicalvishvas@gmail.com
Ambité
Excursionist
30 1 3
@VishvasMishra it will vary, but ive already implementet an ef/else statement regarding Product Tags, that way i can sort them

Thank you so much
0 Likes
VishvasMishra
Shopify Partner
202 40 46

Hope the above solution will help you

For Design, Development and custom changes Hire Me.
If your problem solved then Like & Accept this Solution.
Email ID: technicalvishvas@gmail.com
0 Likes
LovisShop
Excursionist
32 0 2

Thank you so much

LovisShop
Excursionist
32 0 2

@VishvasMishraWow that was like a Wonder,

your the best, stay save.

 

Thank you so so so so much

Lovis from Ambité

0 Likes
VishvasMishra
Shopify Partner
202 40 46

Welcome, for any future help please let me know

For Design, Development and custom changes Hire Me.
If your problem solved then Like & Accept this Solution.
Email ID: technicalvishvas@gmail.com
LovisShop
Excursionist
32 0 2

@VishvasMishraOne more Question... How can i make that the same dropdown menu from the Product appears in the Checkout?

 

Thanks so much, your the best coder ever

Lovis

0 Likes