1

Is there a variable for the invoice date (invoice created on...) in Magento 2? I would like to add this to the standard template for invoice pdfs.

Thanks in advance!

1

yes there is. Similar to order the invoices get a timestamp "created_at".

protected $order;
public function __construct(
.....
\Magento\Sales\Model\OrderFactory $order,
.......
        ) {
    ...
    $this->order = $order;
    ........
    parent::__construct($context, $data);
}


 public function getInvoiceDetails($order_id){

   $orderdetails = $this->order->loadByIncrementId($order_id);

    foreach ($orderdetails->getInvoiceCollection() as $invoice)
        {
            $invoiceCreatedAt = $invoice->getCreatedAt();
        }
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.