Skip to content

radio_variant_option_label

The radio_variant_option_label macro is used to render a <label> element for a product variant option of radio type.

Definition

{% radio_variant_option_label(options) %}

Input parameters

options

object represents an object of radio variant option label attributes

Option key Type Default Required Description
options.name string "" yes Name attribute of the label
options.formatPriceModification string "" no The price change resulted in selecting this variant.

Example

In this example we render a basic radio variant option label.

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

{{ radio_variant_option_label({
    name: 'Blue'
}) }}

Example

In this example we render a radio variant option label with price modification.

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

{{ radio_variant_option_label({
    name: 'Green',
    formatPriceModification: '+$12.10'
}) }}

Macro source code

{% macro radio_variant_option_label(options) %}
    {{ options.name }}

    {% if options.formatPriceModification %}
        <h-hint>
            <span class="color-neutral-700">({{ options.formatPriceModification }})</span>

            <h-hint-content>
                {{ translate('Selecting this option changes the price') }}: ({{ options.formatPriceModification }})
            </h-hint-content>
        </h-hint>
    {% endif %}
{% endmacro %}