• Saul

    (@slightlyfaulty)


    I’ve just encountered a bug on a client’s site. Please take a look at the linked product page. There’s currently a finite number of stock available for this product. If you try to add more than available, e.g. 50, clicking add to cart triggers this error in DevTools console:

    An invalid form control with name=’quantity’ is not focusable.

    I’ve managed to reproduce this on a fresh install with nothing but WooCommerce and this plugin installed.

    1. Create 2 simple products, enable manage stock, and add 5 quantity each.
    2. In one product, add the other product in the Bought Together tab, and enable Custom quantity.
    3. Go to the product page and try to add 10 to your cart.
    4. An error is triggered because the default (hidden) quantity input is trying to submit with a value of 10 while it has a max="5" attribute, and the browser won’t allow this.

    You can fix this easily by allowing the product’s default max quantity to be used in each item’s quantity input when the Max option is blank. At the moment you are passing 0 as the max_value to woocommerce_quantity_input(), which results in no limit.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug when adding more than max quantity to cart’ is closed to new replies.