开发者

Manual magento order creation - item price original and converted to store currency

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)

Manual magento order creation - item price original and converted to store currency

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 converte开发者_Go百科d 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


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜