- 🇮🇳India rkchallengers
Added the following lines in commer_invoice.module worked to me. Thanks @max
function template_preprocess_commerce_invoice(array &$variables) {
/** @var Drupal\commerce_invoice\Entity\InvoiceInterface $invoice */
$invoice = $variables['elements']['#commerce_invoice'];
$token = \Drupal::token();
$invoice_type_data = $invoice->getData('invoice_type', []);
$invoice_type = InvoiceType::create($invoice_type_data);
$invoice_id = $variables['elements']['#commerce_invoice']->id();
$order_id = \Drupal\commerce_invoice\Entity\Invoice::load($invoice_id)->getOrders()[0]->id();
$order_number = \Drupal\commerce_invoice\Entity\Invoice::load($invoice_id)->getOrders()[0]->getOrderNumber();
$variables['order_id'] = $order_id;
$variables['order_number'] = $order_number;