0
votes

I'm using code below to create order in magento:

 $quote = Mage::getModel('sales/quote');
 $quote->setCheckoutMethod('guest')->save();
 $quote->setStore($store);
 $quote->setForcedCurrency(Mage::getModel('directory/currency')->load($storeCurrency));
 foreach ($productInCardList as $productItem) {
    $product = Mage::getModel('catalog/product')->load($productItem['id']);
    $product->setPrice($productItem['price']);
    $request = new Varien_Object();
    $request->setQty($productItem['qty']);
    $quote->addProduct($product, $request);
 }

 $quote->collectTotals();

 $quote->reserveOrderId();
 $quote->save();
 $service = Mage::getModel('sales/service_quote', $quote); 
 $service->submitAll();
 $orderObj = $service->getOrder();
 // ... code setting billing, shipping address, payment and shipping method.

The order is created, but it shown in sales->orders grid with incorrect G.T. Purchased Price (the amount for USD and EUR are the same)same USD and EUR price on order view

The orders placed thorugh magento front end have correct G.T. Purchased price the initial price in USD (92 USD) and converted price for store in EUR(66 EUR). But orders which is created using code shows the same amount converted in EUR(66 EUR) and USD (66 USD). I would very appreciate if you help me to make the price shown correctly in the order.

Thank you for your help

1
What is $orderObj->getStoreCurrencyCode()? - Benubird

1 Answers

0
votes

To convert a price from currency of store view in which the order is placed to the base currency (which Magento is setup with and is shown in the admin), use the following code:

$basePrice = Mage::app()->getStore()->convertPrice($price, false, false);