2

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 Answer 1

2

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 and acknowledge you have read our privacy policy.

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