Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Quantity selector accepts 0 or negative: how to find and fix it

CNV-144Low impactCould addBy FunnelGuardPublished Updated
On this page

What this issue is

The quantity selector is the number box (or plus and minus buttons) next to Add to cart. This issue means a shopper can type 0, -1 or an empty value and the site accepts it instead of correcting it or showing a clear message.

Two layers can fail. The front end (the HTML input) may have no min attribute, or custom buttons may let the number drop below 1. The back end (the cart or order code) may not reject the value if someone edits it or sends it directly. Fixing only the first layer leaves a gap.

Why it costs you leads or sales

Impact is usually low, because most shoppers never type a zero. But when it happens the results are confusing: an empty cart after clicking Add to cart, a cart line with a negative price, a total lower than expected, or an error page at checkout. A shopper who hits any of these often leaves.

The bigger risk is on stores that do not validate on the server. A negative line can reduce an order total, which is a revenue and stock-accuracy problem rather than only a usability one.

Where a bad quantity breaks the path
  1. Product pageShopper opens the product
  2. Quantity entered0 or -1 is accepted
  3. CartEmpty cart, odd total or error
  4. CheckoutNever reached or wrong amount

A quantity of 0 or -1 is accepted on the product page and causes trouble in the cart.

What the shopper sees

A bad quantity leads to an error or empty cart instead of a helpful correction.

How to check if your site has it

Test the quantity field by hand
  1. Open a product page in a private window

    Use a product that is in stock so stock errors do not hide the result.

  2. Type 0 and click Add to cart

    Good result: the field resets to 1 or shows a clear message. Bad result: an empty cart, a zero-quantity line or an error.

  3. Type -1 and repeat

    Also try a blank field, a decimal such as 1.5, and a very large number such as 99999.

  4. Press the minus button repeatedly

    If your theme has plus and minus buttons, check they stop at 1.

  5. Repeat in the cart

    Change the quantity on the cart page too. It is a separate field and often has different rules.

  6. Inspect the input

    Right-click the field, choose Inspect, and look for min="1" on the input element.

How to fix it

Fix both layers: set a minimum on the input, then make sure the server rejects or corrects anything below 1. The exact place depends on your platform and theme.

Set a minimum quantity of 1
  1. Edit the theme's quantity input

    Go to Online Store > Themes > Edit code. Find the quantity input (often in a product form or quantity snippet) and make sure it has min="1". Themes differ, so search for name="quantity".

  2. Check the cart

    Do the same in the cart template or section. Shopify's cart rejects negative values on its side, but your theme should still show a clear message.

Quantity input with a minimumhtml
<input type="number" name="quantity" value="1" min="1" step="1" inputmode="numeric">
WooCommerce: force a minimum of 1php
add_filter( 'woocommerce_quantity_input_args', function ( $args ) {
    $args['min_value'] = 1;
    $args['step']      = 1;
    return $args;
} );
Server-side check (Node.js example)javascript
function parseQuantity(input) {
  const qty = Number.parseInt(input, 10);
  if (!Number.isInteger(qty) || qty < 1) {
    throw new Error('Quantity must be a whole number of 1 or more');
  }
  return qty;
}

How to confirm it's fixed

Retest after the change
  • Typing 0 resets to 1 or shows a clear message
  • Typing -1 is rejected or corrected
  • A blank field does not create an empty cart line
  • Minus buttons stop at 1
  • Decimals such as 1.5 are rejected or rounded
  • The cart page quantity field follows the same rules
  • A normal order with quantity 2 still reaches checkout
Quantity behaviour

Before

  • 0 or -1 accepted
  • Empty cart or odd total
  • No message shown

After

  • Minimum of 1 enforced
  • Server rejects bad values
  • Clear message if the number is invalid

How to prevent it happening again

This problem usually returns after a theme update, a new theme or a plugin that replaces the quantity box. Keep custom quantity code in a child theme or a documented snippet, so updates do not overwrite it.

Habits that keep it fixed
  • Add the 0, -1 and blank test to your release checklist
  • Retest after theme, page-builder or cart plugin updates
  • Validate quantity on the server for any custom cart code
  • Test on mobile, where plus and minus buttons are common

How FunnelGuard handles this

FunnelGuard does not check this yet. Entering 0 or a negative quantity is a negative-path test, and it is a possible future check rather than something the service runs today.

What FunnelGuard does run nearby is the normal journey: a robot visitor opens the product page, adds the item to the cart and moves through the steps, on a schedule from the EU or the US. If a theme change breaks Add to cart or the cart step, that check can show it, with a screenshot and a likely cause. It will not tell you whether 0 or -1 is accepted.

The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans have a 3-day free trial.

Questions people ask

Why does my quantity field accept 0 or negative numbers?

The input most likely has no min attribute, or a custom theme script lets the value drop below 1. If the server also skips validation, the bad value passes through to the cart. Add min="1" and validate on the server.

How do I set a minimum quantity of 1 on my product page?

Add min="1" step="1" to the quantity input. On WooCommerce, use the woocommerce_quantity_input_args filter. On Shopify, edit the theme's quantity input in Online Store > Themes > Edit code.

Can a negative quantity lower the order total?

On a store with no server-side validation, it can, because a negative line subtracts from the total. Major platforms usually reject it, but custom carts and some plugins may not. Always validate on the server.

Is the HTML min attribute enough to block bad quantities?

No. The min attribute only guides the browser, and it can be edited or bypassed. Your cart or order code must also reject values below 1.

What should happen when someone enters 0 as the quantity?

The field should reset to 1 or show a short message asking for a quantity of at least 1. Some stores treat 0 in the cart as removing the item, which is fine if it is clear to the shopper.

Does FunnelGuard detect a quantity selector that accepts 0 or negative?

No. FunnelGuard does not check this yet, though it is a possible future check. It does run the normal add-to-cart journey on a schedule, so you can test the bad values yourself after changes.

How do I test quantity validation quickly?

Open a product page in a private window and type 0, -1, a blank value and 1.5 into the quantity field, then click Add to cart. Repeat on the cart page, and check you get a correction or message each time.

Does FunnelGuard catch this?

Could add

Not checked yet: could be added to FunnelGuard.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.