0

I've written a custom Twig product template 'commerce-product.html.twig', which uses fields such as {{product_entity.body.value}} and {{product_entity.field_picture.entity.uri.value}} to pull out specific data from my Product type and display them in a Drupal view.

I can't find any way of inserting an "add to cart" button into my template though. How is this done?

a000h
  • 47
  • 8

1 Answers1

0

In your display settings for the product type, have Variations visible and set the format to "Add to cart form".

Then, include {{ product.variations }} in your template.

You can also pull in the product variation fields. For example: {{ product.variation_price }}