0

Our 3rd party shipping software only captures orders that are processing/complete in magento. I would like to auto invoice orders using this payment method and this payment method only. So that as soon as the order is captured, magento auto invoices.

Clarification: Our shipping software (Ship Station) will not process/pull orders from Magento unless they are Processing status. With Check/Money Order Payment method in magento, orders are not automatically moved to that status from PENDING unless the order is manually invoiced in the Magento backend.

I am looking for guidance on how to set up an observer that automatically triggers an order using the Check/Money Order payment method and then a module that automatically invoices that order.

I hope that clarifies my need/question.

  • 2
    Hello kirkbrogan, welcome to Magento SE. We are happy to help you. Your question is not clear at all. Which extension that you are mentioning ? do you have any reference for this ? Do you have some code to show us ? Basically this question is too broad and an off topic here – Rajeev K Tomy Sep 3 '15 at 6:41
0

You should create an simple extension and have some observer to listen sales then do whatever you would like to.

In your etc/config.xml

<global>
  ......
  <events>
         <sales_order_place_after>
            <observers>
                <send_invoice>
                        <type>singleton</type>
                        <class>NameSpace_ModuleName_Model_Observer</class>
                        <method>sendInvoice</method>
                    </send_invoice>
            </observers>
        </sales_order_place_after>
  </events>
  ......
</global>

Now NameSpace_ModuleName_Model_Observer.php

class NameSpace_ModuleName_Model_Observer
{
   public function sendInvoice($observer) {
    $order = $observer->getEvent()->getOrder();

    //check order payment
    if($this->_getPaymentMethod($order) == 'payment_method'){
       if($order->canInvoice())
       {
           $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
           $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
           $invoice->register();
           $transactionSave = Mage::getModel('core/resource_transaction')
           ->addObject($invoice)
           ->addObject($invoice->getOrder());
           $transactionSave->save();

           //send invoice
           $invoice->sendEmail();
       }
    }

    //get payment method code
    protected function _getPaymentMethod($order)
    {
       return $order->getPayment()->getMethodInstance()->getCode();
    }
}

you will have to find out your payment method code and replace with payment_method.

Hope this helps.

  • Adarsh, is there any way you can help me a bit more to integrate this? I'm completely new to magento and am not sure where/how to do what you suggest. – kirkbrogan Sep 4 '15 at 3:46
  • I have explained all in my answer. What specifically you are looking for? – Adarsh Khatri Sep 4 '15 at 3:48
  • does it matter where i place/create the observer code? – kirkbrogan Sep 4 '15 at 5:40
  • Your File path should be NameSpace_ModuleName_Model_Observer.php. Observer class must be inside your Model folder. Did you check simple module development link? – Adarsh Khatri Sep 4 '15 at 5:41
0

Perhaps you could solve your problem by navigating to System > Configuration > Payment Methods, expanding the method that correlates to your Check/Money Order payment method and looking for a "New Order Status" field. If this exists, set it to "Processing" so that your orders skip the pending step entirely and ShipStation will pull them in normally.

I have attached a screenshot as an example. However, my payment method is called "Terms" in this instance. Payment Method Screenshot

If you need a code-level solution to solve this problem, Inchoo has a good post about automatically changing the status or an order. Note that you will not want to automatically ship and complete the order as they do in the example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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