PS PrestaShop Intermediate

Unit price and sale by weight: DataFirefly Unit Price documentation

Installation, settings, product net content, sale by chosen weight, pieces at actual weight and weighing, bulk editor, CSV and troubleshooting.

Updated Module version 1.2.0

Installation

Install the module from Modules > Module Manager > Upload a module using the ZIP file, or drop the dfunitprice folder into the /modules/ directory of your shop and click Install.

On install, the module creates three tables (net contents, sale modes, order weighing) and registers its hooks. It adds no menu entry: everything is set from the module configuration page, the Modules tab of the product page and the order page.

Module settings

The configuration page holds, from top to bottom, the bulk editor, the settings, the list of pieces to weigh, the tools and the compliance report.

Unit price for weights and volumes

Choose the default expression: per 1 kg or per 100 g, per 1 litre or per 100 ml. Lengths are always expressed per metre, surfaces per m², bulk volumes per m³. Each product can override this choice.

Countries forcing 1 kg and 1 litre

ISO codes separated by commas, DE by default. For a visitor from these countries, the unit price is always expressed per 1 kg, 1 l, 1 m, 1 m² or 1 m³, as the German PAngV requires, even if you chose 100 g elsewhere.

Display and positions

  • Show on the product page and Position on the product page: the unit price goes through the native displayProductPriceBlock hook. The after_price position (under the price) suits Classic and derived themes. Change it only if your theme does not call that position.
  • Show in product lists and Position in product lists: categories, search, brands, carousels. unit_price position by default.
  • Show in the cart: under the price of each line.
  • Format: “€12.90 / kg” or in brackets.
  • Text before the unit price: optional and translatable, for example “Price per kilo”.

Hide when equal to the selling price

A 1 kg pack sold per kilo repeats the same amount. Some countries allow hiding it in that case: check the rule of your country before enabling the option.

Hide the native unit price of the theme

Avoids a duplicate on the product page when the theme also shows the native field.

Write into the native PrestaShop fields

The module updates the native unit price, its unit label (for example “/ kg”) and the combination impact. Google Shopping or marketplace feed modules that read these fields get the right value.

Minimum refund for pieces sold at actual weight

Below this difference amount, tax incl., on an order, no credit slip is created. Leave 0 to refund every difference.

Categories where a unit price is mandatory

Used only by the compliance report, which lists the active products of these categories without net content.

Entering a product net content

Open the product page, Modules tab, Unit price and sale mode block. The block saves with its own Save the unit price button, independently from the product form.

  • Net content and Unit: 750 g, 1.5 l, 2.5 m, 12 m² or one piece. Leave empty to show no unit price.
  • Unit price expressed per: for weights and volumes, overrides the module setting on this product.

Under the fields, a green line shows the unit price calculated with the current price while you type. After saving, a preview recalls the price tax incl. without discount, the net content and the resulting unit price.

Combinations

Fill in only the combinations whose net content differs from the product, for example 250 g, 500 g and 1 kg. A combination without value uses the product one. The unit “Same as product” uses the product unit. Combinations created after the page was opened appear once it is reloaded.

The calculation

The unit price is the price shown to the customer divided by the net content, brought back to the chosen reference. It follows the tax incl. or excl. display of the customer group, specific prices and discounts. In the cart, it uses the price of the line.

Sale by customer-chosen weight

Choose the Customer chooses the quantity mode. The net content becomes the size of one step and the product price becomes the price of one step. Example: a 100 g step at €2.50, a customer choosing 700 g adds 7 steps to the cart for €17.50.

  • Minimum and Maximum, in the base unit (g, ml, cm, m², m³): each value must be a multiple of the step. The maximum is optional.
  • Preset buttons: values separated by semicolons, for example 250; 500; 1000, each a multiple of the step and between the minimum and the maximum.
  • Allow a free quantity: shows the +/- selector with direct entry. Without preset buttons, free entry is always shown.

On the product page, the theme quantity field is replaced by this selector, with the limits and the total shown live. The selector also works in the quick view of product lists and keeps the chosen weight when the customer changes combination.

What the module handles for you

  • The native minimal quantity of the product and its combinations is synchronised in number of steps.
  • The maximum is enforced server side: a higher quantity added to the cart is brought back to the maximum.
  • The order line becomes “Coffee (700 g)” in the back office, on the invoice and in the confirmation email.

Stock is still counted in steps, because PrestaShop does not handle decimal quantities. With a 100 g step, enter 50 for 5 kg in stock. The product page block recalls this conversion.

Piece at actual weight

Choose the Piece at actual weight mode for products whose exact weight is only known during preparation: meat, cheese cut to order, fish.

  • Average weight of a piece: this is the net content, for example 1.2 kg. The product price is the price of a piece of that weight.
  • Lightest piece and Heaviest piece: optional, shown to customers as a range. The range must include the average weight.

On the product page, a “Sold at actual weight” box explains the rule to the customer: a lighter piece is refunded the difference, a heavier piece costs nothing extra. The order line becomes “Rib of beef (about 1.2 kg)” or “(2 × about 1.2 kg)”.

Weighing an order

On the order page, the Actual weights panel lists each line concerned with the estimated weight and the amount paid.

  1. Enter the total actual weight of each line, all pieces included, in kg (in l for a volume, in m for a length).
  2. The refund of each line and the total are calculated while you type. A weight more than 50% away from the estimate shows a warning, often a unit mistake (1200 instead of 1.2).
  3. Tick or untick the customer email and the voucher, then click Validate the weights and confirm.

The refund of a lighter line is pro rata: amount paid × (1 − actual weight / estimated weight). A heavier line gives no refund and is never charged extra.

What is created

  • A PrestaShop credit slip for the total difference, visible in the order documents. Its PDF lists the lines and an “Adjustment to the actual weight” table.
  • A voucher for the same amount if the box is ticked, reserved to the customer and valid for one year.
  • An email to the customer in their language with the estimated weights, the actual weights and the refunded amount.

The order invoice carries a note explaining the sale on estimated weight and the adjustment by credit slip. The customer also sees the actual weights in the order details of their account.

The credit slip records the refund but does not send the money back. Unless you give a voucher, refund the amount with your payment provider. A validated weighing is final. The credit slip keeps the line quantity so that the native PDF shows the right amount: PrestaShop therefore considers these pieces as already refunded, and a later refund of these lines is made by amount with your payment provider.

Orders to weigh

The configuration page lists the orders that still contain pieces to weigh, oldest first, with a direct link to each order. Cancelled, failed or refunded orders are not listed.

Bulk editor

At the top of the configuration page, the bulk editor shows your products in pages of 50, filterable by category, by name, reference or ID, and limited by default to those without net content yet.

  • Net contents written in the name or reference are detected and pre-filled, marked “Detected”. Packs are multiplied (“6 x 33 cl” gives 198 cl), dimensions such as “40×60 cm” are ignored.
  • Changing a value ticks the line. The unit price is calculated live.
  • Select detected sizes ticks every pre-filled line of the page at once.
  • Also fill combinations whose name contains a size: a “Weight – 500 g” combination receives 500 g, without overwriting a value already entered.

Emptying the net content of a ticked line removes the product net content. Products sold by weight or at actual weight are read only in the grid: edit them from their product page.

CSV import and export

The Export CSV block produces one line per product and per combination, for the whole catalogue or one category. Columns: id_product, id_product_attribute, reference, name, net_quantity, unit, reference_unit.

The import accepts the ; or , separator. The net_quantity and unit columns are required, with id_product or reference (product or combination reference). Units: g, kg, ml, cl, l, mm, cm, m, m2, m3, unit. reference_unit accepts 1kg, 100g, 1l or 100ml. An empty net_quantity removes the line. Errors are listed with their line number and do not block the others.

Tools and compliance report

Resynchronise now recalculates the native fields and the minimal quantities of every product set up in the module. Use it after a bulk price import, or when employees without access to the module edit products: PrestaShop does not run a module hooks for a profile that is not allowed to view it.

The compliance report shows the number of products set up and lists up to 300 active products without net content in the mandatory categories, with a link to their product page.

Troubleshooting

The unit price does not appear on the product page

Check that the product has a net content and that the product page display is enabled. If the theme does not call the after_price position, pick price or weight in the settings.

The unit price appears twice

Enable Hide the native unit price of the theme. If the duplicate remains, your theme uses another CSS class for that block: contact us with the theme name.

The quantity field stays visible on a product sold by weight

The theme uses non-standard quantity markup. The chosen weight is still enforced server side (minimum and maximum). Contact us with the theme name for an adaptation.

The native price is not up to date after a price import

Click Resynchronise now.

Compatibility

  • PrestaShop 8.0 to 9.x, the same ZIP covers both branches.
  • Display through the native displayProductPriceBlock hook, tested on the Classic theme.
  • ModuleAdminController architecture, no Composer dependency, PHP 7.2 and above.
  • Interface and emails in English, French, Spanish, German, Italian, Dutch, Polish and Portuguese.
Was this page helpful?

Still stuck? Contact support