Skip to content
Fluid Checkout
  • Demo
  • Features
  • Add-ons
    • Complete Bundle Save 42%
    • Fluid Checkout PRO
    • Google Address Autocomplete
    • Address Book
    • EU-VAT Assistant
  • Pricing PRO
  • Docs
  • Support
  • My account
0,00 € 0 items
Home / Docs / Configure cart quantity fields for decimal quantities

How can we help?

Getting started

  • Do I need to uninstall the free version when upgrading to PRO, or is Fluid Checkout Lite required?
  • Getting Started with Fluid Checkout
  • Translate Fluid Checkout plugins into your language

Features

  • WooCommerce edit cart on checkout — change quantity or remove items from the cart directly at the checkout page
  • Trust symbols — add security badges, trust seals and other trust symbols to strategic places on the checkout, cart and order received pages
  • Order pay – optimized and intuitive design for your WooCommerce Order Pay page
  • Local Pickup — WooCommerce Local Pickup hide shipping address when local pickup is selected
  • International phone numbers — WooCommerce checkout phone number validation and formatting based on country rules
  • Express checkout — quick payment buttons for Google Pay, Apple Pay and other payment methods
  • Design templates — match your brand styles on the WooCommerce Checkout template
  • Billing address positions — choose to display billing address before shipping, inside the shipping step or force shipping and billing address to a single section
  • Account matching / user matching — associate purchases with and existing customer account without logging in

Customizations

  • Change the icon or icon color for the cart button on mobile
  • Move the “Phone” field to the contact step
  • Configure cart quantity fields for decimal quantities
  • Change fields copied from shipping address to billing address
  • Move first and last name fields to the contact step
  • Customize Local Pickup location address and use multiple pickup locations
  • Customize button colors and other button styles
  • Customize colors of elements on Fluid Checkout
  • Customize template files for WooCommerce and Fluid Checkout
  • Customize checkout steps
  • Add custom house number field and make it required
  • Customize checkout fields and adding custom checkout fields
  • Safely add code snippets to your WooCommerce website

Compatibility

  • Compatibility with plugin YITH WooCommerce Cart Messages Premium
  • Compatibility with plugin WooCommerce Delivery Slots by Iconic
  • Compatibility with plugin Mailchimp for WooCommerce
  • Compatibility with plugin WooCommerce Checkout Manager By QuadLayers
  • Compatibility with plugin Breakdance
  • Compatibility with theme Pressmart
  • Compatibility with theme Divi and the Divi Builder
  • Compatibility with WooCommerce Block-based checkout and cart forms
  • Compatibility with theme Botiga
  • Compatibility with theme Atomion
  • Compatibility with theme OceanWP
  • Compatibility with plugin Digits
  • Compatibility with plugin Storefront Powerpack
  • Troubleshooting – jQuery events or vanilla JavaScript events not working
  • Compatibility with theme ZK Nito
  • Compatibility with theme Woodmart
  • Compatibility with plugin “Plugin Organizer”

Troubleshooting

  • Troubleshooting – jQuery events or vanilla JavaScript events not working
  • Troubleshooting – Local pickup prevents customer from proving a shipping address, blocking other shipping methods
  • Troubleshooting – Trust symbols widgets randomly moving to other areas when switching themes

Account & Purchases

  • Can I get a refund for my purchase?
  • Finding my invoice, adding billing details and VAT number
  • New versions updates are not appearing on my website

Development

  • Troubleshooting – jQuery events or vanilla JavaScript events not working
  • Changelog format and semantic version numbers
  • Changelog – Fluid Checkout PRO & Lite
View Categories

Configure cart quantity fields for decimal quantities

The case for decimal quantities #

By default, WooCommerce only allow whole numbers for the quantity fields. However, the use of decimal quantities in WooCommerce can be beneficial in various scenarios:

  • Products Sold by Weight or Length: If you sell products that are measured by weight or length, such as fruits, vegetables, fabric, or liquids, decimal quantities allow customers to purchase precise amounts. For example, a customer may want to buy 0.5 kg of apples or 1.75 meters of fabric. Enabling decimal quantities allows for accurate purchasing based on weight or length.
  • Flexible Measurement Units: Decimal quantities are useful for products that are measured using non-integer units, such as liquids, powders, or granules. For example, if you sell spices by weight or liquids by volume, decimal quantities allow customers to purchase precise amounts, such as 0.5 kg of spices or 1.75 liters of liquid.
  • International Units: Decimal quantities are commonly used for products with international measurement units. For example, if you sell products in a country that uses decimal-based units, such as kilograms, liters, or meters, decimal quantities allow for accurate and precise purchasing based on local measurement standards.
  • Customizable Products: Decimal quantities can be helpful for products that customers can customize or configure. For instance, if you offer products with multiple options or variations, such as custom fabric by the yard or custom paint by the liter, decimal quantities allow customers to specify exact measurements for their customized products.
  • User Convenience: Enabling decimal quantities can enhance the user experience for customers. It allows them to purchase products in the exact quantity they need, without being limited to whole numbers. This can be particularly useful for customers who require precise quantities for their specific needs.

Enabling decimal quantities for product stock #

WooCommerce does not have a built-in setting to enable decimal quantities. However, you can achieve this functionality through the use of third-party plugins or custom code.

Here are some possible ways to enable decimal quantities for products in WooCommerce:

  • Use a WooCommerce plugin: There are several third-party plugins available in the WooCommerce plugin marketplace that add decimal quantity functionality to your store. You can search for plugins using keywords such as “decimal quantities” or “decimal quantities for WooCommerce” to find suitable options.
  • Implement custom code: If you are comfortable with coding, you can implement custom code to enable decimal quantities for products in WooCommerce. Please note that custom code implementation requires careful consideration and testing to ensure compatibility with your theme and other plugins, and it’s recommended to backup your site before making any changes.

It’s important to note that enabling decimal quantities may have implications for inventory management, shipping calculations, and other aspects of your WooCommerce store. Therefore, thorough testing and consideration of the implications of decimal quantities is recommended before implementing this functionality on a live store.

Enabling decimal quantities with Fluid Checkout PRO optimized cart and checkout pages #

Once you have enabled decimal quantities on WooCommerce, you might need to configure Fluid Checkout PRO to allow decimal quantities on the optimized cart page and on the checkout page if the feature to allow customers to edit cart quantities at checkout is enabled.

To configure decimal quantities for the cart quantities on Fluid Checkout PRO, you need to add the following code snippets to your website, adapting it to the correct number steps for the increase “+” and decrease “-” buttons and the number of decimal places you use for quantities on your website.

If you are unsure about how to add the code snippet to your website, check our article:
How to safely add code snippets to your WooCommerce website

Change number of decimal places for quantity fields

/**
 * Change quantity fields expected decimal places for the number spinner script.
 */
function fluidcheckout_change_cart_items_quantity_field_decimal_places( $decimal_places, $cart_item, $cart_item_key, $product ) {
    return 1;
}
add_filter( 'fc_pro_cart_items_quantity_decimal_places', 'fluidcheckout_change_cart_items_quantity_field_decimal_places', 300, 4 );

Change quantity fields increase/decrease step

This code snippet will only change the quantity step attribute on the cart and checkout pages. You might not need to use if your custom code or the plugin you use for enabling decimal quantities already sets this attribute for other pages on your website.

/**
 * Change quantity fields increase/decrease step amount on cart and checkout pages.
 */
function fluidcheckout_maybe_change_cart_items_quantity_step( $step, $product ) {
    // Bail if not on cart or checkout pages
    if ( ! class_exists( 'FluidCheckout_Steps' ) || ( ! FluidCheckout_Steps::instance()->is_cart_page_or_fragment() && ! FluidCheckout_Steps::instance()->is_checkout_page_or_fragment() ) ) { return $step; }

    return .5;
}
add_filter( 'woocommerce_quantity_input_step', 'fluidcheckout_maybe_change_cart_items_quantity_step', 300, 2 );

Allow decimal values for stock quantities

Your custom code or the plugin you use for enabling decimal quantites probably already replaces the stock quantity filter hooks to use a data type that allows decimal values, but here is the code snippet to do that, for the sake of completeness:

/*
 * Replace conversion of stock quantity from integer to float values
 */
remove_filter( 'woocommerce_stock_amount', 'intval', 10 );
add_filter( 'woocommerce_stock_amount', 'floatval', 10 );
Still stuck? How can we help?

How can we help?

Updated on July 19, 2023
Change fields copied from shipping address to billing address
Table of Contents
  • The case for decimal quantities
  • Enabling decimal quantities for product stock
  • Enabling decimal quantities with Fluid Checkout PRO optimized cart and checkout pages
Fluid Checkout

Frictionless Multi-step Checkout for WooCommerce

© 2021-2025 Fluid Checkout OÜ

Terms | Refunds | Privacy Policy | Cookies

Products
  • All products
  • Fluid Checkout PRO
  • Fluid Checkout Lite
  • Google Address Autocomplete add-on
  • Address Book add-on
  • EU-VAT Assistant add-on
Company
  • Support
  • My account
  • Careers Hiring
  • About
  • Affiliates program
  • Homepage
  • Homepage
  • Features
  • Pricing PRO
  • Demo
  • Docs
  • Support
  • My account