Skip to content

product_title_tag_group

The product_title_tag_group macro is used to render a list of tags for a product title indicating a type of a product like a digital product or a set of products.

Definition

{% macro product_title_tag_group(options) %}

Input parameters

product

Product represents a Product object from Object Api.

options

object represents an object of product title tag group options:

Option key Type Default Required Description
options.set boolean false no If set to true the bundle tag will be displayed if a given product is a bundle
options.digital boolean false no If set to true the bundle tag will be displayed if a given product is digital
options.loyalty boolean false no If set to true the bundle tag will be displayed if a given product is used in the loyalty program
options.cssClasses string null no A list of styling classes that will be added to the product title tag group

Example

Rendering a tag list for bundles and digital products.

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

{% set product = ObjectApi.getProduct(6) %}

{{ product_title_tag_group(product, { set: true, digital: true }) }}

Example

Rendering a tag list for bundles, digital products and products in the loyalty program with an additional class.

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

{% set product = ObjectApi.getProduct(6) %}

{{ product_title_tag_group(product, { set: true, digital: true, loyalty: true, cssClasses: 'my-class' }) }}

Example

Rendering a tag list only for products in the loyalty program.

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

{% set product = ObjectApi.getProduct(6) %}

{{ product_title_tag_group(product, { loyalty: true }) }}

Macro source code

{% macro product_title_tag_group(product, options = {}) %}
    {% set isBundle = product.isBundle and options.bundle %}
    {% set isDigital = product.isDigital and options.digital %}
    {% set isLoyalty = product.isUsedInLoyaltyProgram and options.loyalty %}

    {% if isBundle or isDigital or isLoyalty %}
        <div class="tag__group {{ options.cssClasses }}">
            {% if isBundle %}
                <div class="tag tag_quaternary {{ options.tagCssClasses }}">
                    <span class="overline overline_s mb-xs-0 color_neutral-800">
                        {{ translate('Set') }}
                    </span>
                </div>
            {% endif %}

            {% if isDigital %}
                <div class="tag tag_quaternary {{ options.tagCssClasses }}">
                    <span class="overline overline_s mb-xs-0  color_neutral-800">
                        {{ translate('Digital product') }}
                    </span>
                </div>
            {% endif %}

            {% if isLoyalty %}
                <div class="tag tag_quaternary {{ options.tagCssClasses }}">
                    <span class="overline overline_s mb-xs-0 color_neutral-800">
                        {{ translate('loyalty program') }}
                    </span>
                </div>
            {% endif %}
        </div>
    {% endif %}
{% endmacro %}