0

I have to show the invoice collection of logged-in customers in the frontend. I have referred this link how to get current login customer invoice list and shipments in magento 2? invoice-list-and-shipments-in-magento-2 but when I implement this, I'm getting the below error

Exception #0 (Exception): Warning: Invalid argument supplied for foreach()

Please help me to get the invoice collection.

Thanks in advance.

1 Answer 1

0

Please replace your phtml

<?php $_invoices = $block->getInvoiceList() ?>
<?php if ($_invoices): ?>
<?php foreach ($_invoices as $_invoice): ?>
<div class="order-title">
    <strong><?= /* @escapeNotVerified */ __('Invoice #') ?><?= /* @escapeNotVerified */ $_invoice->getIncrementId() ?></strong>
    <a href="<?= /* @escapeNotVerified */ $block->getPrintInvoiceUrl($_invoice) ?>"
       onclick="this.target='_blank'"
       class="action print">
        <span><?= /* @escapeNotVerified */ __('Print Invoice') ?></span>
    </a>
</div>
<?php endforeach;?>
<?php endif; ?>
2
  • I have replaced the code and I'm not getting any data.
    – MagentoDev
    Commented Jan 7, 2021 at 8:02
  • please check logged in customer have any invoices or not?
    – Himanshu
    Commented Jan 7, 2021 at 9:02

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.