Solved

Add Quantity Buttons to Debut Theme

OHutchyHutch
Tourist
7 0 1

I currently have a quantity setup on my products, however the Debut theme doesn't have any css for the increase/decrease value buttons and so it uses the default for your device. How can I make my quantity field look like this

Venture Theme Example (Barlow Backpack - Boxing Bull)Venture Theme Example (Barlow Backpack - Boxing Bull)

instead of this?

Debut's DefaultDebut's Default

I don't care about the font, I just like the buttons. 

Thank you so much,
Owen

Accepted Solution (1)

Jasoliya
Shopify Expert
4817 623 1219

This is an accepted solution.

Hi @OHutchyHutch 

Follow this:

1. Go to theme customize theme editor->select product page->tick "Show quantity selector" box from left side.

qty.png

 

2. Go to section->product-template.liquid ->find {% if section.settings.show_quantity_selector %} and comment code that in between condition (only product-form__item--quantity this div ). and paste bellow:

 <div class="qtydiv">
          <label for="Quantity" class="quantity-selector">Quantity</label>
          <div class="qtybox">
            <span class="btnqty qtyminus icon icon-minus">-</span>
            <input type="text" id="quantity" name="quantity" value="1" min="1" class="quantity-selector quantity-input" readonly="">
            <span class="btnqty qtyplus icon icon-plus">+</span>
          </div>
        </div>

3. Go to Asset->theme.scss file and add this code at bottom

.qtydiv label{display: block;margin-bottom: 12px;letter-spacing: 2.8px;color: #747a7b;}
.qtydiv .btnqty{display: inline-block;cursor: pointer;user-select: none;font-size: 25px;padding: 5px;line-height: 5px;}
.qtydiv .btnqty.qtyminus{margin-right: 8px;}
.qtydiv .btnqty.qtyplus{margin-left: 8px;}
.qtydiv .quantity-input{border: none;border: none;padding: 8px;text-align: center;width: 50px;outline: none;display: inline-block;}
.qtydiv {display: inline-block;padding-right: 15px;padding-top: 10px;}

4. Go to Asset->theme.js and add this code at bottom:

$('.qtybox .btnqty').on('click', function(){
  var qty = parseInt($(this).parent('.qtybox').find('.quantity-input').val());
  if($(this).hasClass('qtyplus')) {
    qty++;
  }else {
    if(qty > 1) {
      qty--;
    }
  }
  qty = (isNaN(qty))?1:qty;
  $(this).parent('.qtybox').find('.quantity-input').val(qty);
}); 

Let me know if you need help.

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here

View solution in original post

Replies 77 (77)
Jess06
Visitor
2 0 1

Hello,

The only thing I can recommend is to recheck the codes posted above. My carts are updating correctly, so I'm not sure what the issue may be. Maybe @LobsterNoodels can help with more insight

saiyam11
Tourist
17 0 1

CODE DIDNOT WORK

 

Dixravi
New Member
6 0 0

@Jasoliya I have followed all the steps you shared and successfully added the Quantity box there... But it is not working, it contains both the buttons + - left and right side but they both are not clickable.

I am a bit confused with this step but I commented on the old quantity selector code. 

2. Go to section->product-template.liquid ->find {% if section.settings.show_quantity_selector %} and comment code that in between condition (only product-form__item--quantity this div ). and paste bellow:

Can you please guide me on what to do now?

Jasoliya
Shopify Expert
4817 623 1219

Which  theme you have?

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Dixravi
New Member
6 0 0

I am using the Debut theme, please help me in adding the product quantity box? I tried your method but it was not working, I was seeing the box but not clickable.

Jasoliya
Shopify Expert
4817 623 1219

Hi @Dixravi 

If you follow proper step then it must work because its for debut theme.

which issue getting? send e store url and password. 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Dixravi
New Member
6 0 0

@Jasoliya As I already said, I have followed the entire tutorial and it worked but the quantity selector is not working. I mean the + and - buttons are not clickable and not adding the quantity as well.

I am a bit confused about the second step, can you please explain me: 

2 Go to section->product-template.liquid ->find {% if section.settings.show_quantity_selector %} and comment code that in-between condition (only product-form__item--quantity this div ). and paste bellow:

Thanks for your help

Jasoliya
Shopify Expert
4817 623 1219

Send sore url will check

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Dixravi
New Member
6 0 0

I have removed that because it wasn't working well and hurting my customers and eventually, I was loosing sales.

 

 

Jasoliya
Shopify Expert
4817 623 1219

ok then without checking code i cant say anything,

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Dixravi
New Member
6 0 0

@Jasoliya Okay I understand it completely, can you let me know what 2nd step means?  

gravpro
Visitor
3 0 0

@Jasoliya  I'm having the same issue. Followed the tutorial exactly (with a few minor css changes) but as soon as I publish the code, clicking the "-" or "+" buttons doesn't do anything.

I'm using the Debut theme. Here's a link to my product page. Thanks so much!

Jasoliya
Shopify Expert
4817 623 1219

Hi,

That's because of you have new theme and in new theme shopify removed Jquery library in build so you have to add Jquery library to make it work, 

You should have to do this:

1. copy code from this library

2. open your asset->vendor.js file and add whole code at bottom of file.

Note: if you don't want to use Jquery code then you must have to convert my Jquery code in JavaScript.

 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
gravpro
Visitor
3 0 0

@Jasoliya I'm not seeing the vendor.js file you're referencing. Is there a way around this?

gravpro_0-1611065294485.png

 

gravpro
Visitor
3 0 0

Got it working by adding the following snippet in my header.liquid file just before </header>

<script src="https://code.jquery.com/jquery-3.4.1.js"></script>

 

Jasoliya
Shopify Expert
4817 623 1219

Yes its same thing but by my given way it will not affect on speed, and direct file adding will bit affect on Js code rendering. 

try to add in top of theme.js file if work. 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
MedSaad
Tourist
8 0 6

i tried this code on narrative theme but the minus plus buttons aren't working can you help me here please

Aravinthmoshi
Shopify Partner
16 0 4

Hi,

 

I have added your code. It is working fine. But the problem is quanitity is not taken in cart section while adding the product. it is showing the quantity:1.  can anyone help me on that?

 

Thanks,

Aravinth.

 

paint-cabin111
Excursionist
16 0 5

Hello, I know this is an old thread but your solution helped me out, however I've run into a new issue implementing it. The plus button is not rendering correctly, it is rendering as a square symbol. I'm not sure what changes need to now be made to the code in order to have it render correctly?

 

Thanks, let me know if I can provide any more info.

Artom
Tourist
5 0 0

Hey!
I need help, I added two codes in .html and .css. Took its proper form on the product page, but after the code, for adding to .js there is no functionality.

Artom_1-1629713065003.png

 


Thanks.

 

 

 

Jasoliya
Shopify Expert
4817 623 1219

send me store url or pm me

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Artom
Tourist
5 0 0

Jasoliya, 

Thank you!

Jasoliya
Shopify Expert
4817 623 1219

Where you have added js code? 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Artom
Tourist
5 0 0

this code

document.getElementsByClassName("qtyminus")[0].addEventListener("click", function (){quantityChange("btn_minus");});
document.getElementsByClassName("qtyplus")[0].addEventListener("click", function (){quantityChange("btn_plus");});
 
function quantityChange(button) {
var input_element = document.getElementById("quantity");
var qty = parseInt(input_element.value);
  
  if (button == "btn_plus") {
    input_element.setAttribute("value", qty=qty+1); 
    } else if (button == "btn_minus" && qty > 1) {
    input_element.setAttribute("value", qty-1); 
    }
};
but not this
$('.qtybox .btnqty').on('click', function(){
  var qty = parseInt($(this).parent('.qtybox').find('.quantity-input').val());
  if($(this).hasClass('qtyplus')) {
    qty++;
  }else {
    if(qty > 1) {
      qty--;
    }
  }
  qty = (isNaN(qty))?1:qty;
  $(this).parent('.qtybox').find('.quantity-input').val(qty);
}); 
Artom
Tourist
5 0 0

, How to add the same look to the cart page as on the product page?

Jasoliya
Shopify Expert
4817 623 1219

You can add same type of html in section->cart-template.liquid file but you have to manage js code more 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Artom
Tourist
5 0 0

How to understand you about js? do you need to add something or refer to the pro?

Jasoliya
Shopify Expert
4817 623 1219

need to do whole js code based on your store so  cant do from front side just need store access pm me,

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here