0

When an invoice is in state_open, a "Capture" button apprears in the upper right of the invoice detail page.

Natively, clicking this button set the invoice state to paid, and the corresponding order state is set to processing.

In my case, I would like to set the order state to complete.

I am then thinking of rewriting the function linked to this button, but I do not manage to find where is located the function...

I read the html of the invoice view page and saw that the url called by the button was :

<button id="id_cd3d65d85e2f0df22c032a0847da7f6d" title="Capturer" type="button" class="scalable save" onclick="setLocation('http://www.myshop.fr/index.php/admin/sales_order_invoice/capture/invoice_id/77/key/485c21c1646791f987c44c5cdffdea2c/')" style=""><span><span><span>Capturer</span></span></span></button>

I followed the path but did not manage to find the function...

Any help please?

1 Answer 1

0

app/code/core/Mage/Adminhtml/Sales/Order/InvoiceController.php line 320

public function captureAction()
    {
        if ($invoice = $this->_initInvoice()) {
            try {
                $invoice->capture();
                $this->_saveInvoice($invoice);
                $this->_getSession()->addSuccess($this->__('The invoice has been captured.'));
            } catch (Mage_Core_Exception $e) {
                $this->_getSession()->addError($e->getMessage());
            } catch (Exception $e) {
                $this->_getSession()->addError($this->__('Invoice capturing error.'));
            }
            $this->_redirect('*/*/view', array('invoice_id'=>$invoice->getId()));
        } else {
            $this->_forward('noRoute');
        }
    }

if you check this line $this->_saveInvoice($invoice); and see this function. you can understand the state changing of order.

protected function _saveInvoice($invoice)
    {
        $invoice->getOrder()->setIsInProcess(true);
        $transactionSave = Mage::getModel('core/resource_transaction')
            ->addObject($invoice)
            ->addObject($invoice->getOrder())
            ->save();

        return $this;
    }
2
  • thank for your answer. As I can see, no where in the function the corresponding order state is changed... when the invoice is captured, the order state is changed to processing. That is what I need to change...
    – Alexglvr
    Dec 3, 2015 at 15:17
  • update the code now you can see the order state changing.. Dec 4, 2015 at 5:39

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.