Product only sells in 10,20,30,40..etc...

Marcus_Forsberg
New Member
10 0 0

Hi!

I'm selling condoms and i want people to be able to pick whether they want 10,20,30... etc.. condoms. 

I did this with variants, but now it's a variant and not a quantity. 

I want it to be amount of condoms instead of shopify treating it as a single variant of the product. 

How do i do this?

0 Likes
Jason
Shopify Expert
10360 158 2010

If you add a quantity picker to the template as a drop down menu you could just limit those values to increments of 10. 

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

You'll also need to make sure the values don't get adjusted on the cart page too but that can wait until later...

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
Marcus_Forsberg
New Member
10 0 0

Thanks man - although i don't know how to limit the values. I'm not a code geek unfortunately. 

 

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

I tried changing 
{% for i in (1..10) %} to 
{% for i in (10..100) %}

I might just be a dumbass?
 

0 Likes
Jason
Shopify Expert
10360 158 2010

I might just be a dumbass?

Nope, that would be me. I made an error in the code (forget to add the "|"). I've adjusted it above.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
Marcus_Forsberg
New Member
10 0 0

Can i add a text to the quantity options? Like:

10 stk. (30,-)
20 stk. (55,-)
30 stk. (80,-)

And then assign the values as being 10=1 and 20=2 30=3 etc...

It's because my product is 10 condoms - so if you align the values as being 1, people think they'll get 1 condom instead of 1x10 condoms. 

And if you set the values as being 10 in the code, the costumer thinks they'll get 10 condoms (as they should get), but instead they'll get 10x10 condoms. 

If you know what i mean. 

0 Likes
Jason
Shopify Expert
10360 158 2010

You mean with this?

<option value="{{ i | times:10 }}">{{ i | times:10 }} stk.</option>

 

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
Marcus_Forsberg
New Member
10 0 0

Yeah but with unique text to each quantity option. Like "10 stk. (text)" "20 stk. (text)" etc. 

And is it possible to the price on the product page to change according to the quantity chosen, instead of going to the cart to check the price?

0 Likes
Jason
Shopify Expert
10360 158 2010

If (text) is going to be different for each quantity you might just find it easier to manually create the dropdown.

<label for="quantity">Qty: </label>
<select id="quantity" name="quantity">
   <option value="10">10 stk. (text)</option>
   <option value="20">20 stk. (other text)</option>
</select>

And is it possible to the price on the product page to change according to the quantity chosen, instead of going to the cart to check the price?

Yes, you'll need to get stuck into some JavaScript for that. Get your dropdown working first.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
Marcus_Forsberg
New Member
10 0 0

Got it working now! Great! Thanks man!

I removed the variants, because i don't need them anymore, but that removes my quantity dropdown menu. 

Is it because of: 

<form method="post" action="/cart/add">{% if product.variants.size > 1 %}

And how would i tell it to show quantity dropdown even though my variants aren't bigger than 1. I can't set it to equal 1, because i might need variants on a product later. 

0 Likes
Marcus_Forsberg
New Member
10 0 0

Second thought, i don't need variants on the website.

I deleted variants and now it works due to product.variants.size == 1%

So, Jason, about that javascript? :P

0 Likes