Add to Cart Quantity Plus & Minus Buttons

Here’s a quick snippet you can simply copy/paste to show a “+” and a “-” on each side of the quantity number input on the WooCommerce single product page.

This snippet comes with a jQuery script as well, as we need to detect whether the plus or minus are clicked and consequently update the quantity input. jQuery might look difficult to many, but the beauty of this is that you don’t need to have a degree in jQuery – just copy/paste and see the magic happen.

<?php
// 1. Show plus-minus buttons
add_action( 'woocommerce_after_quantity_input_field', 'jwc_display_quantity_plus' );
function jwc_display_quantity_plus() {
    echo '+';
}

add_action( 'woocommerce_before_quantity_input_field', 'jwc_display_quantity_minus' );
function jwc_display_quantity_minus() {
    echo '-';
}

// 2. Trigger update quantity script
add_action( 'wp_footer', 'jwc_add_cart_quantity_plus_minus' );
function jwc_add_cart_quantity_plus_minus() {
    if( ! is_product() && ! is_cart() ) 
        return;

    wc_enqueue_js("
        $( document ).on( 'click', 'button.plus, button.minus', function() {
            varqty = $( this ).parent( '.quantity' ).find( '.qty' );
            var val = parseFloat( qty.val() );
            var max = parseFloat( qty.attr( 'max' ) );
            var min = parseFloat( qty.attr( 'min' ) );
            var step = parseFloat( qty.attr( 'step') );

            if ( $( this ).is( '.plus' ) ) {

                if( max && ( max <= val ) ) {
                    qty.val( max ).change();
                } else{
                    qty.val( val + step ).change();
                }
            } else {

                if ( min && ( min >= val ) ) {
                    qty.val( min ).change();
                } elseif ( val > 1 ) {
                    qty.val( val - step ).change();
                }
            }
        });
    ");
}
?>

Comments

73 responses to “Add to Cart Quantity Plus & Minus Buttons”

  1. The mobile app is a game changer. I can play anywhere without any lag or crashing. Highly recommend downloading bcgameapp for a better experience.

  2. The app version is a game changer. I can play anywhere and the connection is always stable. Love 881betloginapp.

  3. I’ve been trying a few different sites lately and this one really stands out. The interface is smooth and the payouts are fair. Definitely giving kcwin33 a go for my nightly sessions.

  4. Top notch experience so far. The graphics are crisp and the winning streaks are real. I’ll be spending a lot more time here for sure. vnlf168

  5. Customer support is top notch. They answered all my questions within minutes. Very reliable service. inyy5678

  6. I felt lucky the moment I joined. The odds are great and the community is very welcoming. Definitely my new favorite spot pkluckybet7

  7. I finally found a platform that actually works smooth. The registration process was a breeze and I was playing in minutes. Check out 5jililoginregister for a great experience!

  8. Finally found a site that doesn’t crash during peak hours. The bonuses are actually fair and easy to claim at xin883.

  9. Really impressed with the customer support and the variety of games available. Everything feels very secure and professional. Give x666lcd a go if you want a quality gaming spot.

  10. Finally found a site that doesn’t lag during peak hours. The customer support is also very responsive and helpful. Great experience with brbetamo so far.

  11. Had a bit of a struggle finding a stable platform but panalokalogin works perfectly on my mobile. Great experience so far with the customer support too.

  12. I feel like my luck has actually improved since I started playing here. The bonuses are generous and the graphics are top notch. It is a total win for me. Visit hoki69slot and see for yourself!

  13. Best gaming experience I have had in a long time. The rewards are fair and the games are addictive. Join me at idstarwin88.

  14. Logging in is so quick and the site doesn’t lag at all. I love how easy it is to manage my account here. winjiliphlogin is the way to go.

  15. The app interface is super smooth and the login process is a breeze. I really love how fast the games load. Definitely a great choice for anyone looking for a reliable platform. Check out 666jililoginapp

  16. I’ve tried a few sites lately but this one feels much smoother. The loading speed is impressive and the interface is very intuitive. Definitely checking out bdnbajje more often!

  17. Very reliable platform with a very secure login system. I feel safe depositing my funds here and the withdrawal is lightning fast. Trust citrabet77login

  18. Really impressed with the customer support team. They answered my questions in minutes. idmpo1881 is definitely a trusted platform.

  19. Fast registration and even faster gameplay. I love the variety of options available on this platform. It’s very refreshing. Visit idhulk123

  20. Really impressed with the variety of games available here. The interface is very user-friendly and the payouts are fair. I’m having a blast! Highly recommend canohuwin to everyone.

  21. Top notch service and very responsive pages. I appreciate the transparency and the fair play rules here. Big thanks to idarena39.

  22. Super impressed with the speed of the site and the quality of the games. It feels very professional and secure. I suggest brbar222.

  23. Simple and efficient. I dont like complicated sites and this one gets straight to the point. Easy navigation and fast loading at ok999login.

  24. Best betting app I have used this year. The updates are frequent and the new games are always exciting. Great job on the development side! br355betapp

  25. Login process is super fast and secure. I appreciate the stability of the platform even during peak hours. Give bosdolarlogin a try if you want a reliable site.

  26. The best place to play Patti! The competition is exciting and the gameplay is very fair. I’m hooked on pkbingopattigame now.

  27. Honestly one of the best platforms I have used lately. The registration was a breeze and I started playing in minutes. Visit 9777bdgame now.

  28. Honestly I was looking for a new spot to unwind after work and this place really delivered. The games load fast and the support team actually listens. Just had a solid win on my first try which made my week. Highly recommend checking it out if you want a smooth ride without the usual hassle. vnjun88v8

  29. Best platform I’ve used in the Philippines so far. The games are exciting and it feels very fair. Highly recommend giving phjljl2 a try if you love winning.

  30. Such an exciting atmosphere! The games are high quality and the rewards are actually achievable. If you like gaming, pkk999casino is a must-visit.

  31. Finally found an app that actually stays stable. The login process is fast and the features are exactly what I needed. Just downloaded it from 2777bedloginappapk and it is top notch.

  32. Just hit a decent jackpot today! The slots here are fair and the graphics are amazing. Definitely give dragon212slot a try if you enjoy spinning.

  33. My friends told me about this place and it did not disappoint. Very fair odds and a great community. bd6777det is my new favorite.

  34. Best place to unwind after work! The game variety is top notch and the community is friendly. Definitely give vipphfun a try tonight.

  35. The registration was a breeze and I was playing within minutes. The bonus options are actually decent compared to other sites. Cheers to akunbosslot for the great service.

  36. Best gaming experience I’ve had in a while! The interface is very friendly for beginners and the bonuses are generous. Love playing on yono777games during my break.

  37. The interface is very user-friendly and the payouts are legit. I’ve been playing here for a week and I’m loving the vibe at phbw29.

  38. The slot selection is massive and the hit rate seems much better than other sites I have used. Really enjoying the vibe here. Try 50jilislot

  39. Really impressed with the payout speed here. It is rare to find a site that is this honest and fast. Great job to the phkishph team!

  40. Quick and secure access every time. I appreciate the stability of this portal. For the fastest entry go with bosku777login.

  41. The graphics on this site are amazing and the slots are actually fair. I had a great run last night. You guys should really try dino69slot if you love the thrill.

  42. This place really brings the luck. I had a great winning streak last night and the customer support was very helpful with my withdrawal. Visit warunghoki888 for some good vibes.

  43. If you are looking for the best slot experience, this is it. The graphics are stunning and the wins feel rewarding. Get it at pkwinlislotsgamedownload

  44. The game variety here is insane! I spent the whole weekend exploring the slots and the bonuses are actually fair. Love the vibe of jilihotcasino

  45. The live action here is just incredible. It feels like I am actually in the casino without leaving my couch. Definitely check out idbalivegas.

  46. Finally found a site that doesn’t lag during peak hours. The experience on phkkk777 has been super stable so far.

  47. This site has a great selection of Jili games that actually pay out. I’ve spent a few hours here and the experience has been purely awesome. Check out phjili65.

  48. Great bonuses for new members and the app is very stable. I really enjoy the variety of games on 500jiliapp.

  49. The graphics are stunning and the gameplay is very addictive. I had a blast playing here last night. Definitely check out citrabet777.

  50. Finally found a platform that doesn’t lag during peak hours. The customer support was also very helpful when I had a question about my bonus. Big shoutout to bdluckbdbet.

  51. The graphics are amazing and the gameplay is just top notch. It feels like a real casino from the comfort of my own home. Big shoutout to ss7777casino.

  52. Really impressed with the speed of the deposits here. It is hard to find a platform that doesn’t lag during peak hours, but vnsk168 handles it like a pro.

  53. Great selection of games and the payouts are handled very efficiently. I trust this site for my leisure time. Check out bigobet899 if you want a fair game.

  54. The graphics are stunning and the gameplay is so fluid. It is honestly one of the best gaming experiences I have had in a while. Check out bdvk777game now.

  55. The bonuses they offer are actually decent and not just clickbait. I had a blast playing on bdfk77 last night!

  56. I’ve tried a few sites lately but this one is actually smooth. The payouts are fast and the interface is very user friendly. Highly recommend phjili4 for anyone looking for a reliable spot.

  57. Solid platform with some of the best odds I’ve seen. I feel like I have a much better chance of winning here. Big thanks to kr55bet.

  58. The login process is super quick and I never encounter any server downtime. Everything is just very efficient. Head over to bdfg66login now.

  59. I love the variety of games available on this site. There is always something new to try and the bonuses are actually fair. Visit vnwen88

  60. Setting up my account took less than two minutes. The navigation is intuitive and I didn’t get lost at all. idsersanbet is top notch.

  61. The graphics are stunning and the gameplay is fair. I had a great winning streak yesterday! Cheers to idmodal777

  62. Finally found a place where the login process is actually seamless. No lagging and the bonuses are actually fair. Love the vibe here. 8cassinobetlogin

  63. The game selection is huge and the graphics are crisp. It feels like a premium experience from start to finish. Love spending my free time on phlodibet999.

  64. The VIP experience here is legit. The exclusive perks and the priority service make a huge difference. It feels like a premium club. win222viplogin

  65. This place has such a fun vibe and the bonuses are actually generous. It is my new favorite way to unwind after work. Cheers to phokfunph for the awesome service.

  66. I’ve tried a few platforms lately but this one really stands out. The interface is super smooth and the payouts are fast. Definitely my new go-to spot! bdmostplaybet

  67. Quick withdrawals are what I care about most and this place delivers. No long waiting times or weird requirements. I trust iddtg288 for my gaming sessions.

  68. The app is a game changer. I can play whenever I have a break at work without any hassle. Great job on the bd5666betapk software.

  69. I love how transparent everything is here. No hidden fees or weird rules just pure gaming fun. You should definitely visit pkck9999 for a great experience.

  70. Finally found a platform that doesn’t complicate the deposit process. Everything is straightforward and transparent. I trust vngp88 with my gaming budget.

  71. This is probably the best platform for local players right now. The game variety is insane and the login process is very secure. Give jilikobetph a try.

  72. Great graphics and very responsive customer support. ph58jilicom definitely knows how to treat their players right.

  73. Best betting odds I have seen in a long time. It is easy to navigate and the live updates are spot on. I totally trust br55llbet with my plays.

Leave a Reply

Your email address will not be published. Required fields are marked *