1. What this module does

Turn square metres, metres and wall sizes into the right number of packs, pieces or rolls. On the product page the module adds a small calculator: the customer types the area of a room (or its length and width), the lengths of the walls, or the height and widths of the walls to paper, and the calculator answers how many packs, pieces or rolls to order, what they cover and what they cost. One button writes that number into the quantity field of your theme; the customer then adds the product to the cart with the theme's own button.

Three calculations are available, chosen for each product or for a whole category:

  • Area to packs — tiles, panels, flooring, insulation: square metres to packs, with a waste allowance.
  • Running metres to pieces — skirting boards, profiles, trims: metres to pieces, with a waste allowance.
  • Wallpaper to rolls — walls to rolls, by whole strips matched to the pattern repeat.

The module never changes a price and shows no price per square metre. It works in metric units only (metres, square metres, centimetres). Its settings belong to a product, not to a combination. It shows no calculator in quick view and does not check the stock (PrestaShop does that when the quantity is set and when the product is added to the cart).

Works with PrestaShop 1.7.8, 8.x and 9.x (PHP 7.2.5 or newer), with the Classic and Hummingbird themes and with multistore.

2. Installation

  1. Download the module from My account → Order history at addonspresta.com.
  2. In your Back Office, open Modules → Module Manager and click Upload a module.
  3. Drop the ap_areacalculator_v1.0.0.zip file and wait for the confirmation.
  4. Click Configure on the module card.

If you have shell access, you can also unpack the zip into modules/ and run php bin/console prestashop:module install ap_areacalculator from the shop folder.

Nothing changes in your shop until a product or a category has settings. After the installation the module is switched on, but no product has a calculator yet, and a product page without a calculator does not even load the module's files. To start with a category of tiles sold in packs of 1.44 m²:

  1. Open Modules → Module Manager → Area & Pack Calculator → Configure (in a multistore, first select one shop in the Back Office header).
  2. In Category defaults, click Add defaults for a category.
  3. Choose the Category, choose Area to packs in Calculation, type 1.44 in One pack covers (m²) and click Save.
  4. Open Test a product, type the ID of a tile and a sample area, and click Test: you see which settings apply and the result, line by line.
  5. Open the product page in your shop: the calculator is under the Add to cart button.

For a single product, use the module's panel on the product page instead (section 4, "Settings of a product").

3. How it works

What the customer sees

A block titled "Calculate how much you need" (or your own heading) with a small calculator icon. By default it is open and sits right under the Add to cart button. The fields depend on the calculation of the product:

  • Area to packs. The choice "How do you want to enter the area?": "I know the area" (one field "Area (m²)") or "I will enter the dimensions" (a row "Length (m)" × "Width (m)"; "Add another area" adds up to five rectangles, which are added together, for an L-shaped room for example; "Remove" takes a row away). Then the list "Waste allowance".
  • Running metres to pieces. "Length (m)", with "Add another length" for up to five lengths (one per wall, for example), added together. Then "Waste allowance".
  • Wallpaper to rolls. "Wall height (m)", "Wall width (m)" with "Add another wall" for up to five walls, added together, and "Width without wallpaper (m), optional" with the hint "Only parts that get no wallpaper from floor to ceiling. Do not subtract windows or doors: strips are still needed above and below them."

The customer types in metres (square metres for an area), with a decimal comma or a decimal point: 3,6 and 3.6 are the same. Spaces between thousands are ignored (1 250,5); other thousands separators are not accepted (1.250,5 is refused with "Enter a number, for example 12.5"). A length is kept to the millimetre (3 decimals) and an area to the square centimetre (4 decimals); digits typed beyond that are rounded up, so a typed 12.3456 m counts as 12.346 m — never less than what was typed. The only exception is the width without wallpaper, which is rounded down, because it is subtracted.

The result appears while the customer types, in a list of lines (shown below for each calculation), with the numbers written the way the visitor's language writes them. A line "With waste allowance" is left out when the waste is 0 %. When Show the total price is on, the last line is "Total price" (section "Total price" below).

Under the result:

  • the button "Set the quantity to 12" (with the number of the result) writes the number into the theme's quantity field. The theme then reloads the price and the availability for that quantity, as when the customer types the quantity; the calculator says "The quantity is set to 12." and moves the keyboard focus to the theme's Add to cart button. The module adds nothing to the cart: the customer still clicks Add to cart;
  • the note "The shop shows the final price, with any volume discount, once the quantity is set." (only with the total price);
  • for wallpaper, the note "Counted in whole strips of the wall height plus 10 cm for trimming, matched to the pattern repeat. Windows and doors are not subtracted." (with your trimming allowance instead of 10).

Minimum quantity. When the result is smaller than the minimum quantity of the selected combination, the button sets that minimum, the line "Minimum order quantity: 3." says why, and the total price is for that quantity.

Messages. A message appears under a field when its value cannot be used: "Enter a number, for example 12.5" and "This value is too large." while typing; "Fill in this field." and "Enter a number greater than zero." once the customer leaves the field. For the whole form: "The total is too large for this calculator.", "That is more than can be ordered at once. Please contact us." (more than 1,000,000), and for wallpaper "This width must be smaller than the walls together." and "One roll is shorter than one strip for this wall height. Please contact us about this wallpaper." There is no result and no button while a message is shown. The limits: up to five rows; one side of a rectangle or one wall up to 1000 m; an area (or the rectangles together) up to 100,000 m²; lengths up to 100,000 m together; a wall height up to 20 m; walls up to 1000 m together.

Typed values stay. When the customer chooses another combination or the theme reloads the product after a quantity change, the calculator keeps what was typed and computes again with the new price. Nothing is saved: the values live only in the open page and are gone when the page is closed.

The result is an aid. It is worked out from the sizes the customer types and the sizes you enter for the product. The customer remains responsible for measuring the room and for the quantity ordered; the module cannot check the measurements. The rules below are chosen so that the calculator orders slightly too much rather than too little.

Area to packs

The size of one pack: One pack covers (m²), as printed on the pack.

  1. Area = the typed area, or length × width of each rectangle, added together.
  2. With waste allowance = area × (100 + waste) ÷ 100.
  3. Packs needed = area with waste ÷ the area of one pack, always rounded up to a whole pack: 11.01 packs means 12.
  4. Covered area = packs × the area of one pack: what the packs really cover.

Example: a room of 3.6 m × 4.2 m, waste allowance 10 %, one pack covers 1.44 m².

  • Area: 3.6 × 4.2 = 15.12 m²
  • With waste allowance: 15.12 × 1.10 = 16.632 m²
  • Packs needed: 16.632 ÷ 1.44 = 11.55, rounded up to 12 packs
  • Covered area: 12 × 1.44 = 17.28 m²
  • At 25.00 € a pack the total price is 12 × 25.00 = 300.00 €.

Running metres to pieces

The size of one piece: Length of one piece (m).

  1. Length = the typed lengths added together.
  2. With waste allowance = length × (100 + waste) ÷ 100.
  3. Pieces needed = length with waste ÷ the length of one piece, always rounded up to a whole piece.
  4. Covered length = pieces × the length of one piece.

Example: four walls of 4.2 + 3.6 + 4.2 + 2.7 m, waste allowance 10 %, skirting boards of 2.4 m.

  • Length: 14.7 m
  • With waste allowance: 14.7 × 1.10 = 16.17 m
  • Pieces needed: 16.17 ÷ 2.4 = 6.7375, rounded up to 7 pieces
  • Covered length: 7 × 2.4 = 16.8 m

The calculation uses the total length, as shops quote skirting boards: it does not plan the cuts wall by wall. The waste allowance is there for the offcuts.

Wallpaper to rolls

The sizes of one roll, as printed on its label: Roll width (cm), Roll length (m) and Pattern repeat (cm) (empty or 0 for a wallpaper without a pattern to match). Wallpaper is hung in strips from the ceiling to the floor, so the calculator counts whole strips (the strip method):

  1. Strip length = wall height + the trimming allowance (setting Trimming allowance for wallpaper (cm), 10 cm by default). With a pattern repeat, it is rounded up to the next multiple of the repeat, because every strip has to start at the same point of the pattern.
  2. Strips from one roll = roll length ÷ strip length, rounded down: only whole strips count, the rest of a roll is an offcut. When one roll is shorter than one strip, there is no result and the customer sees "One roll is shorter than one strip for this wall height. Please contact us about this wallpaper."
  3. Wall width to cover = the wall widths added together, minus the width without wallpaper.
  4. Strips needed = wall width to cover ÷ roll width, rounded up.
  5. Rolls needed = strips needed ÷ strips from one roll, rounded up.

Example: walls of 4 + 3 + 4 + 3 m, 2.50 m high; rolls 53 cm wide and 10.05 m long, pattern repeat 64 cm, trimming allowance 10 cm.

  • Strip length: 2.50 + 0.10 = 2.60 m, rounded up to the next multiple of 0.64 m: 5 × 0.64 = 3.20 m
  • Strips from one roll: 10.05 ÷ 3.20 = 3.14, rounded down to 3
  • Wall width to cover: 14 m
  • Strips needed: 14 ÷ 0.53 = 26.4, rounded up to 27
  • Rolls needed: 27 ÷ 3 = 9 rolls

The same wallpaper without a pattern repeat: strip 2.60 m, 10.05 ÷ 2.60 = 3.87, still 3 strips from one roll, so again 9 rolls.

What is and is not subtracted. Windows and ordinary doors are not subtracted: the short strips above and below them are cut from full strips, and a calculator that orders one roll too few is worse than one that orders one roll too many. Only what gets no wallpaper from floor to ceiling — a fitted wardrobe, a doorway that reaches the ceiling — belongs in "Width without wallpaper (m), optional". There is no waste allowance in this calculation: the trimming allowance and the pattern repeat are the waste of wallpaper. An offset (half-drop) match is counted like a straight match.

Total price

"Total price" = the quantity that the button sets × the price the product page shows for the selected combination, in the visitor's currency, with the theme's tax label (tax included or excluded) when the theme shows one. After a click on the button the theme reloads the price for that quantity, so a volume discount of the product appears in the total. Cart rules and vouchers are applied only in the cart. No total price is shown when Show the total price is off, when the visitor's customer group does not see prices, or when the product's price is 0.

When the button is not shown

  • In catalogue mode, and for a product that is not available for order, the calculator shows the quantities only: no button, and a total price only when your shop shows prices in catalogue mode.
  • When the theme has no quantity field the module can find (section 7).

Where the calculator is not shown

  • In quick view: the calculator needs room, and a quick view opened from a product page would mix two quantity fields.
  • On a product without settings (neither its own nor of a category), or with "No calculator" (section 4).
  • When Enable the calculator is off, or the module is disabled in the Module Manager.
  • Without JavaScript in the browser.

Themes. The calculator is printed by the hook displayProductAdditionalInfo ("Under the Add to cart button") or displayProductActions ("In the Add to cart block"); Classic (1.7.8, 8 and 9) and Hummingbird call both. It takes the fonts, colours, fields and buttons of your theme. A theme developer can also place it anywhere on the product page with {widget name='ap_areacalculator'} (see README.md in the module's zip).

Combinations. A product has one set of settings for all its combinations. The total follows the price of the selected combination, but the size of a pack, piece or roll is the same for every combination. A product whose combinations have different pack sizes should not use the calculator: switch it off for that product ("No calculator"), or sell the pack sizes as separate products, each with its own settings.

Who may see and change the settings of a product. The rights are set per profile in Advanced Parameters → Team → Permissions.

  • To see the panel on the product page, an employee needs the module's View permission and view access to Catalog → Products.
  • To save in the panel, the employee also needs the module's Configure permission and edit access to Catalog → Products. Otherwise the panel shows the values as text with the note "You can see the settings but not change them: that needs the Configure permission of the module and edit access to Catalog > Products." A SuperAdmin may always do everything.
  • On PrestaShop 8 and 9 the product page of the Back Office opens only with edit access to Catalog → Products.
  • The configuration page of the module (category defaults, products, test, settings) needs the Configure permission.
  • The panel saves through a hidden technical page of the module named "Area & Pack Calculator". Hidden pages are not listed on the Permissions page, so the module gives the read access of this page to every profile at installation, and to every profile created later (also to profiles created while the module was disabled, when you enable it again). That access grants nothing by itself: it only lets the panel's requests reach the module, where the permissions above decide. It is removed from every profile when the module is uninstalled.

What happens to the settings.

  • Deleting a product, or removing it from a shop of a multistore, deletes its settings in that shop.
  • Deleting a category deletes its defaults; a category taken out of a shop stops giving its defaults in that shop.
  • Deleting a shop deletes its settings and defaults.
  • Duplicating a product does not copy its calculator settings. Set them on the copy again, or rely on the category defaults.
  • Uninstalling or resetting the module deletes all of them (section 6).

Personal data, connections, e-mails. The module stores no personal data: only your settings, the defaults of your categories and the sizes of your products. What the customer types is never sent to the server and never stored: it lives only in the open page. The module sets no cookie and uses no browser storage. It makes no outgoing connection — no licence check, no statistics, nothing to addonspresta.com or any other server. It has no cron job and sends no e-mails.

Failures. If the calculator cannot be shown, the product page is shown without it, and one line at most per hour is written to Advanced Parameters → Logs, starting with "Area & Pack Calculator:".

4. Features and settings

Open Modules → Module Manager → Area & Pack Calculator → Configure. The Help box at the top links this manual and the module page at addonspresta.com in the language of your Back Office, gives our support address and shows the installed version. Below it are four tabs: Category defaults, Products, Test a product and Settings.

Fields of sizes accept a decimal comma or point. A value with more decimals than the field keeps is refused (extra zeros, as in 1.4400, are fine).

Category defaults

"A product without settings of its own uses the defaults of its category. Defaults also cover the subcategories; when several categories of a product have defaults, the deepest one wins. Settings of a single product are on its page: Catalog > Products > the product > Modules > Area & Pack Calculator." The defaults belong to one shop: in the All shops or a group context the tab says "Category defaults belong to one shop. Select one of your shops in the header to manage them."

The list shows Category, Calculation, Parameters (for example "One pack covers 1.44 m² · Default waste: 10%") and the Actions Edit and Delete (after the question "Delete the defaults of this category?"; then "Defaults deleted."). Add defaults for a category opens the form; a shop can have defaults for up to 500 categories.

The form: Category (when adding, a list of the categories of the shop that have no defaults yet), then the fields below without "Use the defaults of the category". Save stores them ("Defaults saved."), Cancel goes back to the list. When a value is wrong, nothing is saved and the form shows the message above your values.

Which settings a product gets, in this order:

  1. The product's own settings, from its panel on the product page — a calculation, or "No calculator".
  2. Otherwise the defaults of its categories: every category the product is associated with counts, not only its default category, and a category's defaults also cover its subcategories. When several of them have defaults, the deepest category wins (a subcategory before its parent); at the same depth, the category that holds the product's default category; then the lower ID.
  3. "No calculator" works at every level: on a product it stops every category default for that product; on a category it stops the defaults of its parent categories for that category and its subcategories ("No calculator" here stops the defaults of a parent category for this category and its subcategories.).
  4. Nothing at all: no calculator.

Test a product tells which of these applies to a product.

The fields of a calculation

The same fields are used in the category form and in the product panel; only the fields of the chosen calculation are shown, the others are ignored.

  • Calculation — Area to packs, Running metres to pieces, Wallpaper to rolls or No calculator; in the product panel also Use the defaults of the category (the product has no settings of its own).
  • One pack covers (m²) — area to packs: "The area one pack covers, as printed on it, for example 1.44. Up to 4 decimals." From 0.0001 to 10,000.
  • Length of one piece (m) — running metres: "For example 2.4 for a skirting board of 240 cm." Up to 3 decimals, up to 1000.
  • Roll width (cm) — wallpaper: "For example 53." From 1 to 1000, up to 1 decimal.
  • Roll length (m) — wallpaper: "For example 10.05." Up to 3 decimals, up to 1000.
  • Pattern repeat (cm) — wallpaper: "As printed on the label, for example 64. Leave empty or 0 when the wallpaper has no pattern to match." Up to 1000, up to 1 decimal.
  • Default waste (%) — area and running metres: "The waste allowance chosen when the page opens. Leave empty to use the default of the settings." A whole number from 0 to 100. A value that is not among the Waste allowance options (%) is added to the customer's list for that product or category.

Settings of a product

On the product page: Catalog → Products → the product → Modules tab → Area & Pack Calculator (when other modules also have a panel there, choose it in the list of modules of that tab), the same on PrestaShop 1.7.8, 8 and 9. The panel says what the product uses now — its own settings, "This product uses the defaults of its category." or "The calculator is switched off for this product." — and what it would use without settings of its own, for example "Without settings of its own this product uses the defaults of the category "Tiles": Area to packs, One pack covers 1.44 m²."

Choose the Calculation, fill in the sizes and click Save the calculator settings: "The calculator settings of the product were saved." The panel saves at once; you do not have to save the product, and the product's own Save button does not save the panel. To go back to the category defaults, choose Use the defaults of the category and save. Under the fields: "The settings apply to every combination of the product. Leave the calculator off for a product whose combinations differ in pack size."

The panel needs a product that has been saved once ("Save the product first: the calculator can be set for a product that already exists.") and, in a multistore, one shop selected in the header (section 5).

Products

"Products with settings of their own": the products that have settings in their panel, in the shops of the Back Office context that you manage, 50 per page: ID, Product (the name is shown to employees who may view Catalog → Products; the others see "—"), Shop (in a multistore), Calculation ("No calculator" for a product switched off), Parameters and the link Open the product. It is read-only; "No product has settings of its own." while the list is empty.

Test a product

Type a Product ID and click Test. The test works in the context of one shop and changes nothing. It answers with the product, which settings apply and why:

  • "Own settings of the product."
  • "Defaults of the category "Tiles" (the product is in it or in one of its subcategories)."
  • "No calculator: the product is switched off on its page."
  • "No calculator: the category "Tiles" switches it off."
  • "No calculator: neither the product nor its categories have settings."
  • "No product with this ID in this shop."

and the line of the calculation with its sizes. Add a sample in Area (m²), length (m) or wall width (m) (and Wall height (m, wallpaper only) for wallpaper) to see the result line by line, as the customer would; Waste (%) left empty uses the default that applies to the product. With Enable the calculator off, the test adds "The module is switched off in Settings: nothing is shown in the shop." The product's name is shown to employees who may view Catalog → Products; the others see its ID.

Settings

Saved for the shop or shop group selected in the Back Office header with Save; "Settings saved." confirms it. When a value is wrong, nothing is saved and the form shows the message above your values.

Enable the calculator

On after the installation. "Off: nothing is shown in the shop and no file of the module is loaded there." All settings stay.

Waste allowance options (%)

"What the customer can choose for cuts and breakage, for example: 0, 5, 10, 15. Used by the area and the running metres calculations." Whole numbers from 0 to 100, separated by commas, at most 8, each one once. Default 0, 5, 10, 15.

Default waste allowance (%)

"The option chosen when the page opens. A product or a category can have a default of its own." It must be one of the options. Default 10.

Place of the calculator

  • Under the Add to cart button (default) — a block of its own below the button, in every theme. The installation puts the module first in that place, before the other modules there (the share buttons, for example); you can move it in Design → Positions (displayProductAdditionalInfo).
  • In the Add to cart block — right under the quantity and the button, on a line of its own. It is not shown there in catalogue mode.

Start open

On after the installation. "No: only the heading is shown until the customer clicks it."

Show the total price

On after the installation. "The number of packs, pieces or rolls multiplied by the price the product page shows. Never shown to visitors who do not see prices."

Heading

One field per language, up to 80 characters of plain text (the characters < and > are refused). "Leave empty to show "Calculate how much you need", translated into the language of the visitor."

Trimming allowance for wallpaper (cm)

"Added to the wall height for every strip of wallpaper, to trim at the ceiling and the skirting. Usually 10." A whole number from 0 to 50.

5. Multistore

Settings are saved for the shop or shop group selected in the Back Office header. Values saved with All shops apply to every shop that has no value of its own. In the All shops or a group context only an employee who manages every shop of that context can save ("Select one of your shops in the header to change the settings: in the All shops or group context they also apply to shops you do not manage.").

Category defaults and the settings of a product belong to one shop. Select the shop in the header first. In the All shops or a group context the Category defaults and Test a product tabs ask for one shop, and the panel on the product page says "Choose a shop in the header to set the calculator of this product: every shop has its own settings." (on PrestaShop 8 and 9 the product page itself asks for one shop). Nothing is copied between shops: the same product can be sold in packs of 1.44 m² in one shop and have no calculator in another. The panel is shown only for products of a shop that you manage. Products lists the products of the shops of the context that you manage.

Each storefront uses the settings, defaults and product settings of its own shop. One licence covers every shop of the installation.

6. Uninstall

Module Manager → Area & Pack Calculator → Uninstall deletes the calculator settings of every product, the defaults of every category and every setting of the module, in every shop. PrestaShop first asks "Uninstalling deletes the calculator settings of all products and categories. Continue?". The module drops its two tables, deletes its settings and its hidden technical page with the access given to the profiles. Reset in the Module Manager does the same and then installs the module again, empty. There is no way back except a backup of the database.

Disable keeps everything: while the module is disabled the shop shows no calculator, the panel is not shown on the product page and nothing can be saved in it. When you enable it again, profiles created meanwhile get the access to the hidden page, and the settings of products and categories deleted meanwhile are removed. Switching off Enable the calculator in the settings hides the calculator in the shop and keeps the panel.

7. FAQ and troubleshooting

A product shows no calculator. Type the product's ID in Test a product: it says which settings apply and why. Then check:

  1. Enable the calculator is on, and the module is enabled in the Module Manager.
  2. The product or one of its categories has settings, and none of them says "No calculator".
  3. The category with the defaults is still in this shop (a category taken out of a shop gives no defaults there).
  4. You are looking at the product page itself: the calculator is never shown in quick view.
  5. With In the Add to cart block: the shop is not in catalogue mode.
  6. JavaScript is on in the browser.

If it still does not appear, look in Advanced Parameters → Logs for an entry starting with "Area & Pack Calculator:".

The button that sets the quantity is missing, or the quantity does not change. The button is not shown in catalogue mode or for a product that is not available for order. Otherwise the module looks for the theme's quantity field: the field named qty in the form around the calculator, else the field with the id quantity_wanted (Classic and Hummingbird have both). A theme with another quantity field shows the result without the button; a theme whose field does not react to a change of its value does not reload the price. Ask your theme developer to keep the standard quantity field of PrestaShop, or to place the calculator with the widget inside the add-to-cart form (README.md).

The total of the calculator differs from the cart. The calculator multiplies the quantity by the price the product page shows. A volume discount appears once the quantity is set (the theme reloads the price). Cart rules, vouchers and shipping are applied only in the cart.

The result looks too high. Every step rounds towards having enough: digits beyond the millimetre are rounded up, the waste allowance is added, the number of packs, pieces, strips and rolls is always rounded up, and a wallpaper strip is lengthened to the pattern repeat. Walk through the example of section 3 with your numbers, or type them in Test a product: with a pattern repeat of 64 cm, a wall of 2.50 m needs strips of 3.20 m, so a roll of 10.05 m gives only 3 strips.

A value with a comma is refused. Commas and points are both accepted. The value has more decimals than the field keeps: 4 for One pack covers (m²), 3 for Length of one piece (m) and Roll length (m), 1 for Roll width (cm) and Pattern repeat (cm), none for the waste. In the shop, a customer cannot type a thousands separator other than a space.

Can a combination have its own pack size? No. The settings belong to the product and apply to every combination. Leave the calculator off for such a product, or sell each pack size as a separate product.

Can the calculator show a price per square metre, or work in feet and inches? No. It never changes a price, shows no price per square metre and works in metric units only.

"You do not have permission to do this." or no panel on the product page. Seeing the panel needs the module's View permission and view access to Catalog → Products; saving needs also the module's Configure permission and edit access to Catalog → Products (section 3).

"The page has expired. Reload it and save again." The page was open for a long time, or you logged in again in another tab. Reload the page and save again.

A text of the module is still in English in my shop or my Back Office. Open International → Translations → Installed module translations, select the module and your language, and check the translation.

8. Updates and support

Updates are free for life: download new versions from My account → Order history at addonspresta.com and upload them like a new module. Your settings are kept.

Support is included for 12 months from your order: write to mail@addonspresta.com or use the contact form at addonspresta.com (Monday to Friday, 10:00–16:00; we usually answer within 2 business days). Please include your PrestaShop version, the module version and the steps that lead to the problem.

Back to User manuals

Loading...
Back to top