Quantcast
Channel: Magento Expert » shopping-cart
Viewing all articles
Browse latest Browse all 3

If an order is placed how to get the partial amount in Magento?

$
0
0

I’ve produced a hyperlink with Magento admin to produce the invoice for separate item, But whenever I call the function $order->prepareInvoice($qtys) it’ll add

all of the items in invoice even I’m passing just one product.

I’m using the following code:

$order = Mage::getModel(‘sales/order’)->load($this->getRequest()->getParam(‘order_id’));

$count = $order->getTotalItemCount();

$qtys = Array
    (
        [370] => 1
    );

$invoice = $order->prepareInvoice($qtys);
if (!$invoice->getTotalQty()) {
    Mage::throwException(Mage::helper(‘core’)->__(‘Cannot create an invoice without products.’));
}

$amount = $invoice->getGrandTotal();
$invoice->register()->pay();
$invoice->getOrder()->setIsInProcess(true);
$history = $invoice->getOrder()->addStatusHistoryComment(‘Partial amount of $’. $amount .’ captured automatically.’, false);
$history->setIsCustomerNotified(true);
$order->save();
Mage::getModel(‘core/resource_transaction’)
            ->addObject($invoice)
            ->addObject($invoice->getOrder())
            ->save();
$invoice->save();

I would appreciate any suggestions.

The post If an order is placed how to get the partial amount in Magento? appeared first on Magento Expert.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images