Skip to content

Cart Twig functions

You can use cart Twig functions to check whether products can be added to cart, or to format the price value.

ibexa_can_be_added_to_cart()

The ibexa_can_be_added_to_cart() function checks whether the provided product can be added to cart. It eliminates products that are not available, products that do not have a price that corresponds to a currency selected for the cart, and products, for which VAT category is not set. It also eliminates products that have variants but are not one of those variants.

1
{% set is_disabled = (is_disabled or ibexa_can_be_added_to_cart(product) == false)|default(false) %}

ibexa_format_price

The ibexa_format_price filter formats the price value by placing currency code either on the left or on the right from the numerical value.

1
2
3
{% for product.price in product.attributes %}
    {{ product.price.getMoney()|ibexa_format_price }}
{% endfor %}