User Tools

Site Tools


Sidebar

magento_2:price_per_unit

See the way the Price per Unit for Magento 2 extension works.

Guide for Price per Unit for Magento 2

Automatically calculate and display unit prices (base prices) for products in your Magento 2 store. Comply with the pricing requirements of your local law and help customers make fast and informed purchases.

  • Choose from 3 default units or create custom ones
  • Apply units to specific products
  • Show ‘price per unit’ blocks on product, category, and shopping cart pages
  • Customize the format of the ‘price per unit’ block display
  • WCAG Compliance (for Luma and Hyva Themes)
Magento 2 Price Per Unit extension is compatible with Hyvä themes. You can find the amasty/module-price-per-unit-hyva package for installing in composer suggest (Note: the compatibility is available as a part of an active product subscription or support subscription).

General Settings

To start configuring the extension, please navigate to Stores → Configuration → Amasty Extensions → Price per Unit → General.

Enable Price per Unit - Set to Yes to enable the extension and allow unit price display.

Please note that Magento 2 Price Per Unit extension:
  • enables the display of unit prices for simple, virtual, grouped, downloadable, and configurable products;
  • doesn’t support bundle products;
  • takes into account special prices and catalog price rules applied to an actual selling product price when calculating the unit price.

Display Price per Unit on - select store pages and locations where you would like to display unit prices for products:

  • Product Pages
  • Category Pages
  • Shopping Cart Page
  • Mini Cart
  • Checkout Page
This extension is compatible with the One Step Checkout for Magento 2 extension by Amasty, which includes its own Show Unit Price setting aimed at displaying the price per one product item on checkout. If you enable the price per unit display on the checkout page using the Price per Unit extension and simultaneously activate the Show Unit Price option in the One Step Checkout extension, both price per unit and price per item options will be shown on checkout.

Price per Unit Display for Configurable Products

The Price Per Unit extension enables you to calculate and display unit prices individually for each simple (child) option within a configurable (parent) product, considering the actual prices and the Unit Price tab setup on the edit page of each simple product.

Important: To enable price per unit display for the simple (child) products on the frontend, it is necessary to configure the settings not only in the Unit Price tabs on the edit pages of the simple (child) products but also in the Unit Price tab on the edit page of the configurable (parent) product they are linked with.

If you have numerous configurable products and enable the display of price per unit on category pages, please be aware that it may affect your store's performance.

Units Grid

You can conveniently view, manage, and create units all in one place. To access the Unit Grid, navigate to Catalog → Price per Unit → Units.

After enabling the extension, the grid includes three commonly used metrics (weight, lengths, volume) by default:

  • Grams/Kilograms;
  • Milliliters/Liters;
  • Centimeters/Meters.

You also have the flexibility to create custom metrics as needed (e.g. Pounds/Kilograms, Ounces/Pounds, Feet/Inches, Gallon/fl oz, etc.). Simply click the Add New button to create a new measurement unit or click Edit in the Action column to modify an existing one.

Create and Edit Units

After clicking the Add New button on the Units Grid, you’ll need to fill in the following settings:

Unit Name - provide the name of the future unit in a clear way to easily identify it when setting to products.

Product Unit Measure - specify the unit of measurement for the product.

Reference Unit - specify the reference unit for unit price measurement to which the price should be calculated.

Reference Amount - specify the reference amount of measurement used for calculating the price per unit.

Conversion Rate - specify the ratio of product units to the reference unit.

The decimal numbers can also be used.

Price Per Unit Text - define the format of the unit price display on product, category, and shopping cart pages.

Template that is used by default:

{{unit_price}} / {{reference_amount}} {{reference_unit}}

Feel free to combine these variables:

 {{unit_price}}, {{reference_amount}}, {{reference_unit}}, {{measure_unit}}, {{product_amount}}, {{product_price}}.

Also, you can add extra words and symbols between variables to customize the default template according to your needs.

Customized template (example):

 equals {{unit_price}} per {{reference_amount}} {{reference_unit}} 

Unit Creation Examples

To better understand the process of unit creation, we recommend checking out the examples below.

Let’s imagine that you sell:

1. ‘Whey Protein’ supplement weight of 450 Gr for $14.49 and want to indicate its price per unit (1 Kg)

In this case:

  • Product Unit Measure- Grams
  • Product Amount - 450 (for indication in the Unit Price tab on the product edit page)
  • Product Price - $14.49
  • Reference Unit - Kilograms
  • Reference Amount - 1
  • Conversion Rate - 1000 (1000 Gr = 1 Kg).

2. Vitamin B Complex 120 pills pack for $21.99 and want to indicate price per unit (1 count)

In this case:

  • Product Unit Measure - Count
  • Product Amount - 120 (for indication in the Unit Price tab on the product edit page)
  • Product Price - $21.99
  • Reference Unit - Count
  • Reference Amount - 1
  • Conversion Rate - 1

Unit Price Calculation Formula

For a unit price automatic calculation, the extension utilizes the formula: ((product_price / product_amount) * conversion_rate) * reference_amount.

Let’s plug in the values from our examples:

  • (($14.49/450 Gr)*1000)*1 = $32.20 per 1 Kg
  • (($21.99/120 Counts)*1)*1 = $0.18 per 1 Count

You can see the mentioned examples in action by visiting the extension's demo.

Assigning Units to Products

To assign units to a specific product please go to Catalog → Products and open the necessary product. Then scroll to the bottom of the edit page and expand the Unit Price tab.

Product Measuring Unit - select one of the pre-created units from the dropdown.

Product Amount - specify the amount of a particular product.

Frontend Examples

See how the unit/base price block looks on different store pages.

Product Page

Category Page

Shopping Cart Page

REST API Support

The Price per Unit extension includes API support, allowing store admins to perform CRUD actions on unit prices:

  • “/V1/amastyPricePerUnit/management/entityData” method=“POST” - to create unit prices;
  • “/V1/amastyPricePerUnit/management/entityData/:entityId” method=“DELETE” - to delete unit prices;
  • “/V1/amastyPricePerUnit/management/entityData:id” method=“GET” - to retrieve data about a specific unit price;
  • “/V1/amastyPricePerUnit/management/entityData/all” method=“GET” - to obtain the full list of available unit prices on the instance;
  • “/V1/amastyPricePerUnit/product/calculate” method=“GET” - to get the unit price of a particular product.

Find out how to install Price Per Unit for Magento 2 via Composer.

Rate the user guide
 stars  from 1 votes (Details)
magento_2/price_per_unit.txt · Last modified: 2024/04/10 17:05 by kkondrateva