How to get the total of non-paid invoices in the button?

<button class="pay-button" id="open-button">
                    Pay
                    <?php
                    $total=0;
                    foreach ($_invoices as $_invoice): ?>
                    <?php if($_invoice->getData('status') == 0) :
                            $total = $total+$_invoice->getGrandTotal(); ?>
                        <?php endif;?>
                    <?php endforeach;
                    echo $total;
                    ?>
                </button>

Leave a comment

Your email address will not be published. Required fields are marked *