I am trying to get variation type field values from the order entity but I can't find any documentation on this. I am using an event subscriber to run the following code when an order is paid. The code works, but I can't see any reference to the fields in kint and I can't find any references to any kind of "getVariation" or equivalent function online.
/**
* This method is called when the commerce_order.order.paid is dispatched.
*
* @param \Symfony\Component\EventDispatcher\Event $event
* The dispatched event.
*/
public function commerceOrderOrderPaid(Event $event) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $event->getOrder();
$items = $order->getItems();
foreach ($items as $item) {
kint($item);
if ($item->get('type')->target_id == 'purchase_things') {
// 'number_of_things' is a variation type field.
$thingQuant = $item->get('number_of_things');
// The line does not work, obviously.
// I cannot see 'number_of_things' anywhere in kint($item).
}
}
}