How to detect order type (recurring or not) in order confirmation and shipping confirmation email templates?

drupal.stackexchange https://drupal.stackexchange.com/questions/297549

  •  28-02-2021
  •  | 
  •  

Pregunta

When order is placed an emails is sent to the user generated with template commerce-order-receipt--default.html.twig

When order is shipped another email is sent to the user, now generated with template file commerce-shipment-notification.html.twig

How to detect from those 2 files if it's a first order (generated by user action) or it was recurring order (generated automatically, by cron)?

I need a way to display different content inside those emails based on this criteria.

¿Fue útil?

Solución

Found the way - I can check variable order_entity.bundle for order type and it's value can be "default" or "recurring".

However order receipt email is sent only once, when order is placed and not when recurring order is created, so it's not used for recurring order types at all. I guess that's normal.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a drupal.stackexchange
scroll top