themes/BootstrapTheme/templates/bundles/SyliusShopBundle/Product/Show/_variants.html.twig line 1

Open in your IDE?
  1. {% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
  2. <table class="table table-perso" id="sylius-product-variants" {{ sylius_test_html_attribute('product-variants') }}>
  3.     <thead class="card-header">
  4.     <tr>
  5.         <th class="border-0 h6 text-white">{{ 'sylius.ui.variant'|trans }}</th>
  6.         <th class="border-0 h6 text-white">{{ 'sylius.ui.price'|trans }}</th>
  7.         <th class="border-0 h6 text-white"></th>
  8.     </tr>
  9.     </thead>
  10.     <tbody>
  11.     {% for key, variant in product.variants %}
  12.         {% set channelpricing = variant.getChannelPricingForChannel(sylius.channel) %}
  13.         {%  set percentage =  channelpricing.getDiscountedPercentage %}
  14.         <tr>
  15.             <td>
  16.                 {{ variant.name }}
  17.                 {#                {% if product.hasOptions() %}#}
  18.                 {#                    {% for optionValue in variant.optionValues %}#}
  19.                 {#                        <span class="pr-1">{{ optionValue.value }}</span>#}
  20.                 {#                    {% endfor %}#}
  21.                 {#                {% endif %}#}
  22.             </td>
  23.             <td data-js-product-variant-price   class="sylius-product-variant-price"><strong>{{ money.calculatePrice(variant) }}</strong></td>
  24.             {% set inputAttr = {'data-value': money.calculatePrice(variant), 'data-stock': sylius_inventory_is_available(variant)} %}
  25.             {% if channelpricing.discountedPrice is not null %}
  26.                 {% set inputAttr = inputAttr|merge({'data-discounted-value': money.convertAndFormat(channelpricing.discountedPrice)})  %}
  27.                 {% if channelpricing.price > channelpricing.discountedPrice  %}
  28.                     {% set inputAttr = inputAttr|merge({'data-percentage': percentage|round(0) ~ '%'})  %}
  29.                 {% endif %}
  30.             {% endif %}
  31.             <td class="text-right">
  32.                 {{ form_widget(form.cartItem.variant[key], {'label': false, 'attr': inputAttr }) }}
  33.             </td>
  34.         </tr>
  35.     {% endfor %}
  36.     </tbody>
  37. </table>