The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Increase quantity button

Hi there !

I use a select field for 'quantity', with predefined values (from 1 to 10). I discussed this a while back here:
https://forum.foxycart.com/discussion/10874/changing-quantity-field-to-dropdown-on-cart-template

When the quantity increases, it displays a set of custom fields that correlate to the quantity:
https://forum.foxycart.com/discussion/10749/show-custom-fields-when-the-quantity-field-is-increased-on-the-checkout

I need to add a button that increases the quantity when clicked, baring in mind i'm using a select field rather than a number field like the default foxy cart templates.

I put together a quick proof of concept; whilst the value in my select dropdown field changes, the cart is not re-rendered (the totals still reflect the previous value).

What's the best way to go about this ?
Comments
  • fc_adamfc_adam FoxyCart Team
    @saint_malo,

    Thanks for providing a detailed overview and whispering a link to your site.

    This one had me stumped for quite a while, but I managed to narrow it down to some sort of conflict with a javascript file included on your checkout (s.all.min.js). If I used your checkout template on my own test store without that javascript file included, then running jQuery code like this worked fine:
    $("#quantity1").val("2").trigger("change.fc");
    You'll need to review the code that is included within that file to try to work out which code is causing the issues with the select change event.

    I hope that helps!
  • Hi @fc_adam - thanks for the quick response!

    I'm loading jQuery inside s.all.min.js. When I removed this, all works fine. So thanks for the hat tip!

    Quick question - whilst this works if you click on the #button first, if you click on the quantity select field first, then the #button, the jQuery doesn't run.

    Is this my jQuery or something todo with FC javascript ?

    <script>
    $('#button').click(function(){
    $('#quantity1').val('3').trigger('change.fc');
    });
    </script>


  • Ahh, it's my jQuery that is the problem. This works fine:

    $(document).on('click', '#button', function(){
    $('#quantity1').val('3').trigger('change.fc');
    });


    Thanks again for your help.
  • fc_adamfc_adam FoxyCart Team
    @saint_malo,

    I'm glad you got it sorted! Nice one.
Sign In or Register to comment.