“Maximum Available Quantity Has Been Added to Cart” Error in WooCommerce

Seeing the “Maximum available quantity has been added to cart” error in WooCommerce? This happens when a product’s stock limits prevent additional items from being added. Here’s how to fix it.

Why Does This Error Happen?

  • Stock settings are restricting the available quantity.
  • WooCommerce session cache is not updating properly.
  • Custom code or plugins are interfering with cart functionality.

Solutions to Fix the Issue

1. Check WooCommerce Stock Settings

Ensure the product has sufficient stock:

  • Go to Products > Edit Product.
  • Scroll to Inventory settings.
  • Make sure Stock quantity is set correctly.
  • Uncheck “Sold Individually” if you want to allow multiple purchases.

2. Clear WooCommerce and Browser Cache

Cached data may cause quantity issues. Clear cache:

  • Go to WooCommerce > Status > Tools.
  • Click “Clear transients” and “Clear customer sessions”.
  • Clear your browser cache or test in incognito mode.

3. Allow Higher Quantities in WooCommerce

If WooCommerce enforces a limit, override it using this custom code:

function custom_wc_max_quantity($max, $product) {
    return 100; // Set maximum limit as needed
}
add_filter('woocommerce_quantity_input_max', 'custom_wc_max_quantity', 10, 2);

4. Disable Plugins Causing Conflicts

Some plugins, such as stock management or cart limiters, may interfere.

  • Disable plugins one by one to identify conflicts.
  • Check WooCommerce > Status > Logs for error messages.

5. Refresh WooCommerce Cart Session

To force WooCommerce to update cart quantity correctly, add this code:

function refresh_cart_session() {
    WC()->cart->calculate_totals();
    WC()->cart->set_session();
}
add_action('wp_loaded', 'refresh_cart_session');

6. Check Theme Compatibility

If you’re using a custom theme, it might be overriding WooCommerce settings.

  • Switch to a default theme like Storefront or Twenty Twenty-Four.
  • Test if the issue persists.

Final Checks

  • ✔ Confirm stock settings are correct.
  • ✔ Clear cache and WooCommerce transients.
  • ✔ Disable interfering plugins.
  • ✔ Use custom code to override limits if needed.

If you’ve tried all these fixes and still have the error, let us know your setup! 🚀

Related Posts


Custom query filter for order by is causing issue with group by in wordpress

If your custom query filter for ORDER BY is causing issues with GROUP BY in WordPress, it’s li...

How to fork and maintain a WooCommerce Block separately?

Forking and maintaining a WooCommerce block allows you to customize its functionality independently ...

WordPress CSS Issue Caused by User Agent Stylesheet

If your WordPress site’s CSS is being overridden by the user agent stylesheet, it can cause layout...

WP Pagination Not Working for Custom Query: Troubleshooting Tips

Ever struggled with WordPress pagination code? Fret not! We’ve got your back. In this post, we...