Magento: Order has invoice (generated) but 'Total due' > 0

牧云@^-^@ 提交于 2019-12-05 07:21:53

问题


I have a live Magento 1.5.0.1 webshop, with the following problem:

We have received an order, which has been paid for through iDEAL (Dutch online payment service) and an invoice has been auto-generated on payment success. We have also received the amount on our bank account.

The only thing is, we cannot complete the order because of the 'Total due' field being an amount higher than 0 (zero). This must be a bug in our iDEAL-module (which will be dealt with at another moment).

Is there a way to 'force' this particular order to be 'complete' with the Total due field set to 0?

Obviously, PHP-code examples to do so are quite welcome (I am a programmer myself).


回答1:


This might help you.

Example from one of our modules:

$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
if ($order->getTotalPaid() == 0) {
    $invoice = $order->prepareInvoice();
    $invoice->register()->capture();
    Mage::getModel('core/resource_transaction')
        ->addObject($invoice)
        ->addObject($invoice->getOrder())
        ->save();
    $order->save();

This checks if payment was not yet registered(user might send several successful requests by multi clicking) then creates invoice, registers it, captures and save invoice and orders.

EDIT 1

private function markOrderPayd($incrementId, $status) {
        $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
        if ($order->getTotalPaid() == 0) {
            ... 
            $order->save();
            $invoice = $order->prepareInvoice();
            $invoice->register()->capture();
            ...
            Mage::getModel('core/resource_transaction')
                ->addObject($invoice)
                ->addObject($invoice->getOrder())
                ->save();
            $order->save();
            ...

        } else {
            ...
            $order->save();
        }
}

I guess you don't have any check, so 2 invoices are generated.



来源:https://stackoverflow.com/questions/9721345/magento-order-has-invoice-generated-but-total-due-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!