FROM CACHE - en_header

Remove Quantity from a product

Solved
SonicWatts
New Member
2 0 0

I am trying to remove the quantity picker from one of my products as i am using a variant to chose the quantity as there is discounts if you buy more.

 

I think i have found the code and know i need to make a new  template and section to have my page go to this code.
 Capture 1 is the code i believe i need to edit or change.

 

Would anyone be able to help. i am using the Brooklyn Theme

Accepted Solution (1)

Accepted Solutions
Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

This is an accepted solution.

Hey there,

 

Bo here from Shopify Support!

 

That is a really great question and you are absolutely heading down the right path to get this done. You will be able to remove the quantity selector from this product by creating a new template and a new section so let's get started.

  • Go to Online Store > Edit Code.
  • Under the Templates folder select "Add a new template". Select product from the dropdown and you can name it what you want, for this case we will simply call it alternate and create the template.
  • On line six replace:

 

{% section 'product-template' %}

with:

 

{% section 'product-template-alternate' %} 

 

  • Click Save.
  • Under the Sections folder you will select "Add a new section". You will name this new section "product-template-alternate".
  • Go to product-template.liquid and copy all the code. Once copied go back to product-template-alternate and paste replace whatever code is there with what you have copied.
  • At the start of line 329 you will add {% comment %} and at the end of line 334 you will close it with {% endcomment %}. The finished product will look like this: 

  • Click Save. 

Now that you have made this change to the code itself you can go ahead and select that template for your product. 

 

Let me know how this goes and if there is anything else I can assist you with, I'm happy to help!

 

All the Best,

Bo

Bo | Retired Staff Member

View solution in original post

Replies 61 (61)
Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

This is an accepted solution.

Hey there,

 

Bo here from Shopify Support!

 

That is a really great question and you are absolutely heading down the right path to get this done. You will be able to remove the quantity selector from this product by creating a new template and a new section so let's get started.

  • Go to Online Store > Edit Code.
  • Under the Templates folder select "Add a new template". Select product from the dropdown and you can name it what you want, for this case we will simply call it alternate and create the template.
  • On line six replace:

 

{% section 'product-template' %}

with:

 

{% section 'product-template-alternate' %} 

 

  • Click Save.
  • Under the Sections folder you will select "Add a new section". You will name this new section "product-template-alternate".
  • Go to product-template.liquid and copy all the code. Once copied go back to product-template-alternate and paste replace whatever code is there with what you have copied.
  • At the start of line 329 you will add {% comment %} and at the end of line 334 you will close it with {% endcomment %}. The finished product will look like this: 

  • Click Save. 

Now that you have made this change to the code itself you can go ahead and select that template for your product. 

 

Let me know how this goes and if there is anything else I can assist you with, I'm happy to help!

 

All the Best,

Bo

Bo | Retired Staff Member

SonicWatts
New Member
2 0 0

Thanks Bo,

 

Worked a charm

Autonome
New Member
2 0 0

Hi Bo,

I'm also a newbee with Shopify and I have followed your instructions on how to make an alternate product page template and thereafter comment out the Quantity selector.

 

At first view it works fine (no quantity selector appears on the product page where I have assigned the my new alternate product page template:-)) - but when I use the new alternate product template it seems that I loose some of the regular settings. For instance, the Social sharing icons ar also gone and the styling of the submit to card button is gone too.

 

Do I have to do some changes in "settings_data.json", "social-sharing.liquid" or some other setting-files to get the altenate product page to act like my normal product pages.

 

Snap_1.png:

My normal product page

 

Snap_2.png:

The product where I have used the new alternate product Page Template (As you can see, The Social Sharing section is gone and the styling off the submit button is also gone.

 

Can you please guide me in this matter?...thanks in advance....

 

/Ulf

 

Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

Hey there, Ulf! 

 

This tutorial was specific for an unedited version of the Brooklyn theme. Is this the theme that you are currently using? 

 

All the Best,

Bo

Bo | Retired Staff Member

Autonome
New Member
2 0 0

Hi Bo and sorry for the delayed reply.

 

I've solved the issue my self...actually right after I posted my request. It seemed that I just had to update my Shopify settings for that particually the page where I had assigned the new template :-). So all is working great now.

 

But thanks for your rapid reply to my question in the first place 🙂

 

Best Regarda

/Ulf

Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

Brilliant! I am so glad this worked out for you in the end!

 

All the Best,

Bo

Bo | Retired Staff Member

1234567891
New Member
1 0 0

heyy Bo,

can you suggest me the best way to catch variant change event on product page.

 

Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

Hey there, @1234567891 

 

I would recommend posting this query  in our awesome API and Technology Community. I would not know how to implement that kind of tracking, however, someone in the community might! It's the best place to get help from both Shopify's dev team and other developers for assistance with API related questions and development.

 

All the Best,

Bo

Bo | Retired Staff Member

AidanSchaper
New Member
6 0 0

Hi! I want to remove the quantity only from certain products on my store (more than one but not all). How would I go about doing this? I am using Debut theme. Would what was previously suggested work for this? 

 

Also, is there a way to change the name of the quantity selector? Also just for certain products.

 

Any help on this would be greatly appreciated!

Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

Hey there, @AidanSchaper 

 

I would recommend posting this query in the Design Community board to get more eyes on it as this is a relatively old post. I would love to look into it for you so feel free to @Bo me in the new post. 

 

All the Best,

Bo

Bo | Retired Staff Member

mrussett
New Member
3 0 0

Bo, I did this and it worked fine on the Venture theme product page, but then when i view my cart the quantities choice reappears. How do I go about removing the quantities choices on the cart of one specific product?

ThxScreen Shot 2019-09-30 at 4.47.46 PM.jpgScreen Shot 2019-09-30 at 4.48.11 PM.jpg

Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

 

Wonderful!! I am glad to hear that this worked on the product page. Removing the quantity selector for all products in the cart page would be relatively easy, however, having it appear and remove based on the product will be more complicated. If you want it to only not show on certain products I would recommend reaching out to a Shopify Expert.

 

  • Go to Online Store > Actions > Edit Code. 
  • Open the cart-template.liquid.
  • Search for the following:
<p>
                    <a href="{{ routes.cart_change_url }}?line={{ forloop.index }}&amp;quantity=0">{{ 'cart.general.remove' | t }}</a>
                  </p>
                </td>
                <td class="cart__cell--quantity">
                  <label for="Updates_{{ item.key }}" class="cart__quantity-label medium-up--hide">{{ 'cart.label.quantity' | t }}</label>
                  <input type="number" name="updates[]" id="Updates_{{ item.key }}" class="cart__quantity" value="{{ item.quantity }}" min="0" data-line="{{ forloop.index }}" aria-label="{{ 'cart.label.quantity' | t }}">
                </td> 

 

  • Add {% comment %} to the start, right before <p> and {% endcomment %} at the end right after </td>. The finished code will look like this:
{% comment %} <p>
                    <a href="{{ routes.cart_change_url }}?line={{ forloop.index }}&amp;quantity=0">{{ 'cart.general.remove' | t }}</a>
                  </p>
                </td>
                <td class="cart__cell--quantity">
                  <label for="Updates_{{ item.key }}" class="cart__quantity-label medium-up--hide">{{ 'cart.label.quantity' | t }}</label>
                  <input type="number" name="updates[]" id="Updates_{{ item.key }}" class="cart__quantity" value="{{ item.quantity }}" min="0" data-line="{{ forloop.index }}" aria-label="{{ 'cart.label.quantity' | t }}">
                </td> {% endcomment %}
  • Click Save.

Let me know how this goes and if there is anything else I can assist you with, I'm happy to help!

 

All the Best,

Bo

 

Bo | Retired Staff Member

roxysocherry
New Member
3 0 0

Hello,

So tested the solution, using Debut theme as well.

But did not work for me. 

On product page I had 2 buttons showing (capture here).

And I had an error when clicking on one of them.

 

What I'm trying to achieve is removing quantity from product, so when clicking on "buy now" button it redirects to cart without adding a quantity (if there's already 1 product in cart, if 0 than it adds 1, if 1 than adds 0).

 

Screen Shot 2019-11-11 at 11.47.16 AM.pngScreen Shot 2019-11-11 at 11.47.20 AM.png

marbil_1
New Member
1 0 0

Hi Bo,

 

I'm using Brooklyn theme and I would like to remove the quantity box on the cart slider. Is it possible? If yes, please let me know how it could be done!

Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

Hey there, @marbil_1 

 

I would recommend posting this query in the Design Community board to get more eyes on it as this is a relatively old post. I would love to look into it for you so feel free to @Bo me in the new post. 

 

All the Best,

Bo

Bo | Retired Staff Member

AnnCodi39
New Member
2 0 0

Are we also be able to remove quantity selector on the cart page? 

Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

That can be done for sure. What version of what theme are you currently using? These tutorials are very specific to the theme and version. If you would like, you can create a new thread altogether about this in the design forum so other people can chime in on how to help and find the answer you get when they are looking for the same solution! 

 

All the Best,

Bo

Bo | Retired Staff Member

AnnCodi39
New Member
2 0 0

I'm using a third party theme 😞

 

 

Bo
Shopify Staff (Retired)
Shopify Staff (Retired)
1793 197 461

Thank you for confirming, @AnnCodi39. In that case, I would recommend starting a new thread, as the theme is the third party I would not be the best to advise you. You could also hire a Shopify Expert.

 

All the Best,

Bo

Bo | Retired Staff Member