1

I have a twig template for my commerce product, commerc-product--contenttype.html.twig:

<article{{ attributes }}>
  <div class="row">
    <div class="col-xs-6">
      {{ product.field_price_original }}
      {{ product.variation_price }}
    </div>
    <div class="col-xs-6">
      {{ product.field_discount_percentage }}
    </div>
  </div>
  {{ product|without('variation_attributes', 'product.field_price_original', 'product.variation_price', 'product.field_discount_percentage') }}
</article>

I want to print three fields separately first and then print the rest of the content except for the first three fields (which have already been printed).

However, even though this note implies that without can take multiple values, everything is being printed; the without is ignored.

If I try a single value like this:

  {{ product|without('product.field_price_original') }}

The without is still ignored. What might be the cause of this?

Drupal 8.4 and Commerce 2.1

1

You remove the sub-keys below product:

article{{ attributes }}>
  <div class="row">
    <div class="col-xs-6">
      {{ product.field_price_original }}
      {{ product.variation_price }}
    </div>
    <div class="col-xs-6">
      {{ product.field_discount_percentage }}
    </div>
  </div>
  {{ product|without('field_price_original', 'variation_price', 'field_discount_percentage') }}
</article>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.