【问题标题】:Manual magento order creation - item price original and converted to store currency手动创建 magento 订单 - 商品价格原始并转换为商店货币
【发布时间】:2011-07-28 14:45:41
【问题描述】:

我正在使用下面的代码在 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.

订单已创建,但它显示在销售->订单网格中,G.T. 不正确。购买价格(美元和欧元的金额相同)

通过 magento 前端下达的订单具有正确的 GT。购买价格以美元(92 美元)为初始价格,以欧元(66 欧元)为商店的转换价格。但是使用代码创建的订单显示以欧元(66 欧元)和美元(66 美元)转换的相同金额。如果您能帮助我在订单中正确显示价格,我将不胜感激。

感谢您的帮助

【问题讨论】:

  • 什么是 $orderObj->getStoreCurrencyCode()?

标签: magento currency


【解决方案1】:

要将价格从下订单的商店视图的货币转换为基础货币(Magento 设置并显示在管理员中),请使用以下代码:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-17
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    • 1970-01-01
    • 2014-08-11
    • 1970-01-01
    • 2011-07-11
    相关资源
    最近更新 更多