support@kaviolabs.com Same-day reply on weekdays Help & Support Support

Sell by weight or length in OpenCart.

Shoppers enter 1.25 kg or 2.5 m, pick a preset and see the line total while they type. The cart, checkout, order, invoice and stock all use the exact quantity, on OpenCart 4 and OpenCart 3.

  • v1.0.2
  • OpenCart 4.0.2.0 – 4.1.0.4, 3.0.x
  • 30-day refund on a first licence
Admin: unit, step, minimum and maximum per product
Admin order page: measured quantity and unit price on every line
Cart with measured quantities and unit prices

The problem

Why OpenCart cannot take 0.5 as a quantity

OpenCart stores quantities as whole numbers everywhere: in the cart, in orders and in stock. Type 0.5 in the quantity box and it becomes 1, or the product is refused.

Stores that sell cheese, fabric, flooring or paint therefore sell packs, or round up and fix the difference by hand.

Three ways to sell by measure

ApproachHow it worksTrade-off
One option per packOptions such as 250 g, 500 g and 1 kg with price modifiers.No free amounts; option stock counts packs, not kilograms.
Patch the cart with OCMODModify core files so the cart accepts decimals.Breaks on upgrades and clashes with other extensions.
Events with exact stockWhat Sell by Weight & Length doesThe extension keeps the exact quantity and stock next to OpenCart’s whole numbers, using events only.Order lines show quantity 1 with "Quantity: 1.250 kg" underneath, because OpenCart stores whole numbers.

Sell by Weight & Length for OpenCart

How it works

  1. 01

    Choose a sale unit

    In Catalog > Products > Edit, tab Sell by measure: one of 15 units (kg, g, lb, oz, m, cm, ft, yd, in, m², ft², L, ml, gal, fl oz). The product price becomes the price of one unit.

  2. 02

    Set step and presets

    Quantity step up to 4 decimals, minimum, maximum, default quantity and up to 8 preset buttons per product.

  3. 03

    Sell exact amounts

    Line totals are exact (1.250 kg × $12.99 = $16.24, rounded once); orders take the exact stock and canceled orders give it back.

What you get

15 sale units

Weight, length, area and volume, with the unit shown after prices ("/ kg").

Live line total

The total updates while the shopper types; arrow keys move by the step.

Exact decimal stock

Kept next to the core Quantity field, which shows it rounded up so the product stays in stock.

Discounts and taxes

Quantity discounts in the sale unit; taxes, coupons and gateways work unchanged.

Shipping by weight

Product weight is the weight of one unit; the line weight is weight × quantity.

Events only

No core file changes and no OCMOD patches; one licence for OpenCart 4 and 3.

Made for

  • Cheese, meat and deli
  • Coffee, tea and spices
  • Fabric and ribbon
  • Rope, chain and cable
  • Flooring and tiles
  • Paint and liquids

Sell by Weight & Length for OpenCart

Screenshots

How to sell by weight or length in OpenCart

OpenCart stores whole quantities only. For cheese, fabric, cable or flooring, that leaves two workarounds: a "100 g" product bought 13 times, or an option list of fixed sizes. Neither gives you real stock or a readable order.

Sell by Weight & Length adds a decimal quantity field with the unit next to it. The customer buys 1.25 kg, the price is calculated to the cent, and the stock falls by exactly that amount. Built on OpenCart events, with no core changes, no OCMOD and no theme edits.

There are 15 sale units: kg, g, lb, oz, m, cm, ft, yd, in, m², ft², L, ml, gal and fl oz.

What the customer sees

  1. The price shows "/ kg". The quantity field takes 1.25 or 1,25, presets such as 250 g, 500 g and 1 kg fill it in, and arrow keys move by the step.
  2. The line total appears while they type.
  3. A quantity off the step or outside the limits is corrected, and the success message says so.
  4. In the cart each measured product is one line: 1.25 kg + 0.5 kg = 1.75 kg, with "$12.99 / kg" in the unit price column. The mini cart shows "x 1.250 kg".
  5. Orders, e-mails, invoices and the admin order page show "Quantity: 1.250 kg" and "Price per kg: $12.99".

On product lists, Add to Cart adds the default quantity, or the minimum when none is set.

Setup and settings

After installing, turn on the module, which starts disabled. Then open a product, choose the Sell by measure tab, and save.

Sell by measure tab
FieldExampleMeaning
Sale unitKilogramThe product price becomes the price of 1 unit.
Quantity step0.005Up to 4 decimals. It also sets the decimals shown.
Minimum / maximum0.1 / 5Per cart line.
Default quantity0.5Pre-filled, and added from lists.
Preset quantities0.25, 0.5, 1Up to 8 buttons.
Exact stock8.750Empty uses the Quantity field.

How stock works

The core Quantity field holds whole numbers, so it shows the exact stock rounded up: 8.750 kg shows as 9, and the product stays in stock while anything is left. Orders take the exact amount, and canceled orders give it back. If you, an import or another extension sets Quantity to another whole number, that becomes the exact stock.

Quantity discounts work in the sale unit, and the price is chosen by the whole units of the quantity, so 5.5 kg uses the "5 or more" price. Set Weight to the weight of one unit, and shipping follows the quantity.

Things to know before you buy

  • Order lines of measured products have quantity 1 with the exact line total, because OpenCart stores whole quantities only. The real amount shows as an order detail.
  • Payment gateways receive "1 × line total". That is why PayPal and others accept the order.
  • Products bought with a subscription plan are sold in whole units.
  • A product has one sale unit. Sell a pack and a loose version as two products.
  • The core Minimum Quantity field is not used for measured products.
Options compared
Fixed-size optionsDecimal quantities
Any amountNoYes, to your step
Stock in real unitsPer option valueYes
Readable orderOption textQuantity and unit price
SetupOption list per productOne tab per product

Fixed options are enough if you only ever sell 250 g and 500 g bags.

Works well with

The Pantry theme is built for food stores and sold with this extension and the Bulk Product Editor in the Food Store Kit on the packages page. Abandoned Cart Recovery keeps and restores measured quantities exactly. Our guide compares selling by weight across platforms. Get Sell by Weight & Length on the store.

Good starting steps: 0.05 kg for deli, 50 g for coffee, 0.1 m for fabric. Match the step to how you actually weigh and cut, since a step finer than your scales promises what you cannot deliver.

Compatibility

OpenCart 4.0.2.0 to 4.1.0.4, and 3.0.x with a separate package, both in one licence. Tested on 4.1.0.4 and 3.0.5.1. You have 14 days to enter the licence key after installing.

Example setups by product type

Suggested starting values
ProductUnitStepPresets
Cheese or delikg0.050.25, 0.5, 1
Coffeeg50250, 500, 1000
Fabricm0.11, 2, 5
Rope or cablem0.55, 10, 25
Flooringm²0.015, 10, 20

Run a real order before launch. Add a measured product, change the quantity in the cart, pay with your gateway, and check the order, invoice and stock. Then cancel it, and confirm that stock returns. If you use an import tool, remember that a changed Quantity overwrites the exact stock, so feed whole numbers only where they are true.

OpenCart

Sell by Weight & Length for OpenCart at a glance

Sell products by weight, length, area or volume with decimal quantities, unit prices, step/min/max and a live price on the product page (OpenCart 4.x and 3.0.x).

Price
$69 one-time
Version
1.0.2
Compatible with
OpenCart 4.0.2.0 – 4.1.0.4, 3.0.x
PHP
7.4 or newer (as required by your OpenCart version)
Licence
One store, OpenCart 4 and 3 packages, 12 months of updates
Refund
30-day refund on a first licence

OpenCart

The OpenCart products stores buy first

The most requested products on this platform. Each one has its own page, and you can buy it straight on the sales site.

Shop OpenCart on our sales site

Prices, licences, full documentation and instant downloads are on the store.

opencart.kaviolabs.com · 96 extensions · 16 themes

Sell by weight

The same feature on other platforms

Built natively for each platform, not ported. Each version has its own product page, documentation and price.

Guide

Related guide

Guide

Selling by weight compared

How five platforms handle 1.25 kg or 2.5 m, the usual workarounds and what to check before you choose.

Read the guide

FAQ

Questions and answers

Why does the admin order page show quantity 1?

OpenCart stores whole quantities only. A measured product is one order line with the exact line total; "Quantity: 1.250 kg" and "Price per kg: $12.99" under the product name keep the measure.

Will PayPal or Stripe accept the order?

Yes. They receive quantity 1 with the line total as its price, so the sum of the lines always equals the order total.

Do I need to edit my theme?

No. It uses OpenCart events and the standard quantity field of the product page, and works with the default themes of OpenCart 4 and 3 and themes that keep that field.

Does the licence check slow down my store?

No. It runs in the admin panel once a day; the storefront never contacts the licence server.

How does stock work with decimals?

The extension keeps exact stock next to the core Quantity field, which shows it rounded up. Orders take the exact amount, and canceled orders give it back.

Do quantity discounts work?

Yes, in the sale unit. A discount from 5 applies from 5 kg.

Do reward points and coupons still work?

Yes. Taxes, coupons, reward points and totals work as usual.

Can a subscription product be sold by weight?

No. Products bought with a subscription plan are sold in whole units.

Start selling by the kilo or the metre

See every screen and read the full documentation on the product page.

Kavio Labs

Also by Kavio Labs

The same standards, the same support desk and one licence portal on every platform we build for.