I have two Commerce order types, order_a and order_b, which I created at /admin/commerce/config/order-types
.
I'm using Commerce 2 on Drupal 8.
I want to process them differently in hook_commerce_order_presave().
How can I programmatically get the order type? When I check the entity type, it only has commerce_order
, but I want to know what type of commerce order it is. I can't find a method to get the order type specifically.
Here's the code I am using:
function MYMODULE_commerce_order_presave(\Drupal\commerce_order\Entity\OrderInterface $entity) {
if ($entity->isNew()) {
kint($entity->getEntityTypeId());
die();
$entity->bundle()