Sell products only in multiple of 3

Andrea00
Tourist
15 0 0

Hi all,

 

I have a Shopify wine shop, and I am looking for a solution to allow me to keep the unit price but allowing only for quantities that are multiples of 3 (the packaging is only of 3 or 6 bottles). Does anybody know how I could achieve this?

Replies 16 (16)

PeanutButter
Shopify Partner
385 67 181

Hi, can you share the following:

- Theme you are using
- Your store url

Peanut Butter Collective | Shopify Experts
- Was my reply helpful? Please Like and Accept Solution.
- Want to customize and improve your store? Hire us.
- Feel free to contact me us hello@peanutbutter.es
Andrea00
Tourist
15 0 0
PeanutButter
Shopify Partner
385 67 181

cool.  I will provide solution tomorrow if nobody has done before

Peanut Butter Collective | Shopify Experts
- Was my reply helpful? Please Like and Accept Solution.
- Want to customize and improve your store? Hire us.
- Feel free to contact me us hello@peanutbutter.es
PeanutButter
Shopify Partner
385 67 181

hi @Andrea00,

Please try the following:

First of all I recommend making a copy of your theme and testing code edits there instead of doing it on your live theme.  

Open file Snippets/product-form.liquid and go around line 46.  Search for this line:

      <input class="product-form__quantity-input" type="number" id="Quantity-{{ section.id }}" name="quantity" value="1" min="1" pattern="[0-9]*">

 and replace it with:

      <input class="product-form__quantity-input" type="number" id="Quantity-{{ section.id }}" name="quantity" value="3" min="3" step="3" pattern="[0-9]*">

 As you can see, we have changed the initial and minimum values for the quantity input and we have set the step size to 3.

If this is what you are looking for please tell me and I will provide code to modify the quantity selectors for the cart page and dropdown carts

Peanut Butter Collective | Shopify Experts
- Was my reply helpful? Please Like and Accept Solution.
- Want to customize and improve your store? Hire us.
- Feel free to contact me us hello@peanutbutter.es
PeanutButter
Shopify Partner
385 67 181

hi @Andrea00 where you able to check my proposed solution?

Peanut Butter Collective | Shopify Experts
- Was my reply helpful? Please Like and Accept Solution.
- Want to customize and improve your store? Hire us.
- Feel free to contact me us hello@peanutbutter.es
Andrea00
Tourist
15 0 0

Hey @PeanutButter it works! Could you send the other necessary codes? Thank you so much!

PeanutButter
Shopify Partner
385 67 181

The next one is for the cart page at https://tessere-winery.myshopify.com/cart

On Sections/cart-template.liquid, on line 189. Replace this:

                <input id="quantity_{{ item.key }}" class="cart-item__qty-input" value="{{ item.quantity }}" type="number" pattern="\d*" min="1" name="updates[]" required data-cart-item-input-quantity>

 with:

                <input id="quantity_{{ item.key }}" class="cart-item__qty-input" value="{{ item.quantity }}" type="number" pattern="\d*" min="3" step="3" name="updates[]" required data-cart-item-input-quantity>

 

I will try to figure out the last one while you check this one out

Peanut Butter Collective | Shopify Experts
- Was my reply helpful? Please Like and Accept Solution.
- Want to customize and improve your store? Hire us.
- Feel free to contact me us hello@peanutbutter.es
PeanutButter
Shopify Partner
385 67 181

ok, and the last one is for the cart drawer (cart that appears from the right when you just have added to cart)

On file Snippets/cart-drawer.liquid, on line 138, you have to change this:

                <input id="quantity_{{ item.key }}" class="cart-drawer__item-quantity" value="{{ item.quantity }}" type="number" pattern="\d*" min="1" aria-label="{{ 'cart.general.item_quantity' | t }}" data-cart-item-input-quantity>

to this:

                <input id="quantity_{{ item.key }}" class="cart-drawer__item-quantity" value="{{ item.quantity }}" type="number" pattern="\d*" min="3" step="3" aria-label="{{ 'cart.general.item_quantity' | t }}" data-cart-item-input-quantity>

 

Peanut Butter Collective | Shopify Experts
- Was my reply helpful? Please Like and Accept Solution.
- Want to customize and improve your store? Hire us.
- Feel free to contact me us hello@peanutbutter.es
Andrea00
Tourist
15 0 0

All works in the copied theme! However it works if I do the selection with the arrows, if I write manually the number it allows the "wrong" values, like 14, 8... Do you have an idea how to avoid that as well?

PeanutButter
Shopify Partner
385 67 181

@Andrea00 are you sure about this?

if I add wrong value and click the add to cart button, it does not allow for me to add to cart:

Screen Shot 2021-01-25 at 23.38.27.png

Screen Shot 2021-01-25 at 23.39.52.png

Peanut Butter Collective | Shopify Experts
- Was my reply helpful? Please Like and Accept Solution.
- Want to customize and improve your store? Hire us.
- Feel free to contact me us hello@peanutbutter.es
Andrea00
Tourist
15 0 0

Yes, that works like a charm, the error message doesn't appear when you manually type a different quantity and the item is already in the cart.

PeanutButter
Shopify Partner
385 67 181

hi @Andrea00 I didn't fully understand your last message.  Are you being able to add a number of products which is not a multiple of 3 to the cart? how are you doing that and what browser are you using?

Also, would you want to allow users to change the value of the input field by typing or would it be ok to only allow to change it via the buttons?

Peanut Butter Collective | Shopify Experts
- Was my reply helpful? Please Like and Accept Solution.
- Want to customize and improve your store? Hire us.
- Feel free to contact me us hello@peanutbutter.es
Andrea00
Tourist
15 0 0

@PeanutButter  I am able to select only multiples of 3 to be added to the cart without getting the error you posted in the screenshot. The problem is when the items are in the cart and then the customer is able to type in and change the quantity to something that is not a multiple of 3.

 

Would be great if would be possible to have the same error message as in the screenshot above.

LucianoSAV
Visitor
1 0 0

hi @PeanutButter ,

We're planning to sell sparkling stuff and almost the same need of @Andrea00; I say almost because we'll sell single bottle or multiples of 3.

I tried to setup the solution you suggested but there's no file Snippets/product-form.liquid in code editor.

Any suggestion?

Thanks for helping.

 

 

Andrea00
Tourist
15 0 0

@PeanutButter what if now I wanted to have one collection where the normal quantities, also when not multiples of 3 are allowed?

nchachula
Tourist
3 0 1

@PeanutButter Is there a way to do this based on a "Tag"? I have different products that are sold in different quantities.