I want to return more details about order, customer, product and shipping after order placement so can handle my own custom API. I have this code in successAction
method in :
app/code/core/Mage/Checkout/controllers/OnePageController.php
public function successAction()
{
$session = $this->getOnepage()->getCheckout();
if (!$session->getLastSuccessQuoteId()) {
$this->_redirect('checkout/cart');
return;
}
$lastQuoteId = $session->getLastQuoteId();
$lastOrderId = $session->getLastOrderId();
$lastRecurringProfiles = $session->getLastRecurringProfileIds();
if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
$this->_redirect('checkout/cart');
return;
}
// start
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
$customerID = $order['customer_id'];
$customerFirstName = $order['customer_firstname'];
$customerLastName = $order['customer_lastname'];
$customerEmail = $order['customer_email'];
$orderID = $order->getId();
$shippingAddressID = $order['shipping_address_id'];
foreach ($order->getAllItems() as $item) {
$orders['orders']['items'][] = array(
'productID' => $item->getProductId(),
'sku' => $item->getSku(),
'orderedQty' => $item->getQtyOrdered(),
);
echo "Product ID: ". $item->getProductId()."<br/>";
//send my api
}
//end
$session->clear();
$this->loadLayout();
$this->_initLayoutMessages('checkout/session');
Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
$this->renderLayout();
}
The problem is: there are another products returned. For more clear when I choose one product and do checkout then place order, I see my product and another product returned. how to prevent?