Overview
Sell products by weight, length, area or volume. Customers buy exactly what they need: 1.25 kg of cheese, 2.6 m of fabric, 3.33 m² of flooring. The product price is the price of one unit; the total is price × quantity.
Requirements: WordPress 6.7+, WooCommerce 10.1+ (tested with 11.2), PHP 7.4-8.3. Works with block themes and classic themes, the Cart and Checkout blocks and the classic shortcodes, and High-Performance Order Storage (HPOS).
Installation
- In WordPress go to Plugins > Add New > Upload Plugin, choose
kv-sell-by-measure-<edition>.zip, click Install Now and Activate. WooCommerce must be active. - Open WooCommerce > Settings > Sell by measure and enter your licence key (own-site edition) or your CodeCanyon purchase code (CodeCanyon edition). The WooCommerce.com edition needs no key.
- Open a product, tab Product data > Sell by measure, choose a Sale unit and click Update.
Updating: upload the new zip (WordPress offers "Replace current with uploaded"). Settings, products and orders are kept.
Uninstalling: deactivate and delete the plugin. Product and category settings are deleted only when Remove data on uninstall is on. Orders are never changed. Without the plugin WooCommerce treats quantities as whole numbers again, so finish or cancel open orders with decimal quantities first.
Configuration
Product settings
Products > Edit product > Product data > Sell by measure (simple and variable products; variations use the settings of their parent product).
| Field | Example | What it does |
|---|
| Sale unit | Kilogram (kg) | Use the category default (default), Whole items (standard) or one of 15 units: kg, g, lb, oz, m, cm, ft, yd, in, m², ft², L, ml, gal, fl oz. With a unit, the regular price is the price of 1 unit. |
| Quantity step | 0.05 | Smallest change of the quantity, up to 4 decimals. Quantities are snapped to the step (2.33 m becomes 2.3 m with a 0.1 step). Its decimals are the decimals shown. Empty = 0.01. |
| Minimum quantity | 0.1 | Smallest quantity per cart line. Empty = one step. |
| Maximum quantity | 5 | Largest quantity per cart line. Stock still applies. Empty = no limit. |
| Default quantity | 0.5 | Quantity in the field when the page opens and the amount added from product lists. Empty = the minimum. |
| Quick amounts | 0.25, 0.5, 1, 2 | Up to 8 buttons under the quantity field ("250 g", "500 g", "1 kg", "2 kg"). With decimal commas use semicolons: 0,25; 0,5; 1. |
| Length x width | on | Area units (m², ft²) only: customers enter length and width; the quantity is the area rounded up to the step. |
Stock: keep stock in the sale unit (Inventory tab); decimals are allowed (125.5). Orders reduce it exactly and cancelled orders restore it.
Shipping weight: enter the weight of one unit (1 kg for a product sold per kg). WooCommerce multiplies it by the quantity.
Category defaults
Products > Categories > Edit, section Sell by measure defaults, has the same fields. Products whose sale unit is Use the category default use the settings of their first category (or parent category) that has a unit.
Settings
WooCommerce > Settings > Sell by measure
| Setting | Default | What it does |
|---|
| Unit after prices | on | "/ kg" after the price on product pages and product lists |
| Quick amounts | on | Quick amount buttons on product pages |
| Live total | on | "Total: $16.24 (1.25 kg at $12.99 / kg)" on product pages |
| Remove data on uninstall | off | Delete the settings and the product/category settings when the plugin is deleted |
| Licence key / Purchase code | empty | See below |
Licence
- Own-site edition (kaviolabs.com): enter your Kavio Labs licence key. Without a valid key (after a 14-day start period, or when the key is invalid, revoked or for another domain), measured products are sold in whole items again. Settings, carts and orders that already hold decimals are kept, and the admin is never blocked. Local development addresses (localhost, *.test, private IPs) always work.
- CodeCanyon edition: enter your purchase code for updates and support. All features work without it.
- WooCommerce.com edition: licensed through your WooCommerce.com subscription; there is no licence field.
The check runs once a day from the admin area. It sends only the site address and the key or code to kaviolabs.com.
FAQ
Does it change WooCommerce templates?
No. It uses WooCommerce hooks, the Store API and the checkout filters of the Cart/Checkout blocks. There are no template overrides.
Why does the stock-hold note of a block checkout say "× 1" for 1.3 kg?
WooCommerce holds stock for unpaid block checkouts in whole numbers. The real stock reduction is exact (1.3).
Are coupons per kg?
"Fixed product discount" coupons apply per unit of the quantity ($1 off × 2.5 kg = $2.50), the same as for 2 pieces. Percentage and cart coupons work as usual.
Analytics "items sold" shows whole numbers. WooCommerce Analytics stores items sold as integers. Revenue is exact.
Can I sell one product by weight and another per piece?
Yes. Only products with a sale unit (their own or from their category) are measured. Choose "Whole items (standard)" to take a product out of its category default.
What about variable products?
Variations use the parent product's unit and limits. Each variation has its own price per unit, and the live total follows the selected variation.