I want to have separate twig templates for each product type in drupal 8 commerce to customize them.

is there any way to do that?


by default drupal 8 uses commerce-product.html.twig. you can find it from modules/contrib/commerce/modules/product/templates/ and copy and paste it to your template folder in your theme.

and to create separate template file for each product type you can add --product type at the end of file name. for example if you have shoes product type then you should create a file commerce-product--shoes.html.twig.

then drupal uses the new template for shoes product type only.

| improve this answer | |

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.