Dec 31, 2011
kalpesh

Magento Admin – Forcing Invoice and Ship button together

Ever wondered what if you want to do invoice and shipment with just one click in your website admin? Yes, Magento allows you to integrate both these in one step.

Edit your module’s config.xml and Observer.php for this to happen.

config.xml snippet:

<events>
            <sales_order_place_after>
                <observers>
                    <namespace_module>
                        <type>singleton</type>
                        <class>Namespace_Module_Model_Observer</class>
                        <method>doForceInvoiceWithShipment</method>
                    </namespace_module>
                </observers>
            </sales_order_place_after>
</events>

Every time a order is placed, frontend as well as backend, your observer method will be called which will force invoice and shipment to show in one button in Manage Orders for particular order at backend.

Observer.php snippet:

public function doForceInvoiceWithShipment($observer) {
        $order = $observer->getOrder();
        $orderId = $order->getIncrementId();
        Mage::getModel('sales/order')->loadByIncrementId($orderId)->setForcedDoShipmentWithInvoice(true)->save();
}

Now you can place a order and check at backend under Sales->Orders clicking on latest order to see “Invoice & Ship” button integrated rather than “Invoice” and “Ship” button separated.

3 Comments

  • This is just now the kinda info I was looking! Thanks.

  • very useful code , thank you

  • You saved my day. Thanks a lot, man.

Leave a comment

 

Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!

Certifications

Honor

Recognition

Magento top 50 contributors

Magento top 50 contributors

Contributions