Skip to content

price_unit

The price_unit macro is used to render a unit price of the product.

Definition

{% macro price_unit(price, label) %}

Input parameters

price

string A unit price of the product

label

string if specified, an additional label will be rendered next to the unit price

Example

A base usage of the macro.

{% from "@macros/price_unit.twig" import price_unit %}

{{ price_unit('$9.54') }}

Example

Unit price with an additional label.

{% from "@macros/price_unit.twig" import price_unit %}

{{ price_unit('$9.54', 'Example label') }}

Macro source code

{% macro price_unit(price, label) %}
   {% from "@macros/price_base.twig" import price_base %}

   {{
      price_base(price, label, {
         price: 'price_xs',
         priceValue: 'price__value_secondary js__unit-price'
      })
   }}
{% endmacro %}

Macros reference