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
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top