bigcartel

mathematical operations on the variable product.has_default_option


I need to perform mathematical operations on the variable product.has_default_option.

how can I do?

this is my snippet:

{% for product in products %}
                    <li class="{{ product.css_class }}">
                        <a href="{{ product.url }}">
                            <img alt="Image of {{ product.name | escape }}" src="{{ product.image | product_image_url | constrain: '900' }}">
                            <b style="font-family: 'Bevan', cursive;text-transform: uppercase;font-size: large;">{{ product.name }}</b>
                                                <i style="font-family: 'Bevan', cursive;text-transform: uppercase;font-size: medium;">{{ product.default_price | money: theme.money_format }}</i>

                                                <p> {{ product.default_price * 2 | money: theme.money_format }}</p>

                            {% case product.status %}
                                {% when 'active' %}
                                    {% if product.on_sale %}<em>On Sale</em>{% endif %}
                                {% when 'sold-out' %}
                                    <em>Sold Out</em>
                                {% when 'coming-soon' %}
                                    <em>Coming Soon</em>
                            {% endcase %}
                        </a>
                    </li>
                {% endfor %}

Solution

  • You can use the times filter, so to multiply that variable by 2 you'd do the following:

    {{ product.default_price | times: 2 }}