Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento-商店视图和多种货币-始终使用基础货币结账_Php_Magento_Paypal_Currency - Fatal编程技术网

Php Magento-商店视图和多种货币-始终使用基础货币结账

Php Magento-商店视图和多种货币-始终使用基础货币结账,php,magento,paypal,currency,Php,Magento,Paypal,Currency,我有一个magento网站 我们有一家商店 在商店中,我们有多个商店视图(美国、欧盟和英国) 每个商店视图都有自己的货币等 默认配置(主)下的基础货币为英镑 我的问题是显示货币运行良好。每个商店视图都有自己的单独价格(无自动转换)。一切似乎都在正常运转。但是,在最终支付电子邮件和与支付提供商(PayPal/Sage)的实际联系上。始终使用基础货币。尽管每个商店视图都以货币显示 我的问题是,为什么PayPal、电子邮件等不使用商店查看货币。尽管金额、显示货币等工作正常?当我在一家相当大的Mag

我有一个magento网站

  • 我们有一家商店
  • 在商店中,我们有多个商店视图(美国、欧盟和英国)
  • 每个商店视图都有自己的货币等
  • 默认配置(主)下的基础货币为英镑
我的问题是显示货币运行良好。每个商店视图都有自己的单独价格(无自动转换)。一切似乎都在正常运转。但是,在最终支付电子邮件和与支付提供商(PayPal/Sage)的实际联系上。始终使用基础货币。尽管每个商店视图都以货币显示


我的问题是,为什么PayPal、电子邮件等不使用商店查看货币。尽管金额、显示货币等工作正常?

当我在一家相当大的Magento商店遇到这个问题时,这个快速修复方法对我来说非常有效:

请注意,该修复程序可能无法开箱即用,但需要进行一些调整

这里是一些解决方案。 您可以自定义一些代码 如果您使用的是Paypal Express, \app\code\core\Mage\Paypal\Model\Express.php

protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
{
    $order = $payment->getOrder();

    // prepare api call
    $token = $payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
    $api = $this->_pro->getApi()
        ->setToken($token)
        ->setPayerId($payment->
            getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))
        ->setAmount($amount)
        ->setPaymentAction($this->_pro->getConfig()->paymentAction)
        ->setNotifyUrl(Mage::getUrl('paypal/ipn/'))
        ->setInvNum($order->getIncrementId())
        **->setCurrencyCode($order->getOrderCurrencyCode())** // should be used getOrderCurrencyCode();
        ->setPaypalCart(Mage::getModel('paypal/cart', array($order)))
        ->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)
    ;
    if ($order->getIsVirtual()) {
        $api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
    } else {
        $api->setAddress($order->getShippingAddress());
        $api->setBillingAddress($order->getBillingAddress());
    }

    // call api and get details from it
    $api->callDoExpressCheckoutPayment();

    $this->_importToPayment($api, $payment);
    return $this;
}
\app\code\core\Mage\Paypal\Model\Standard.php

public function getStandardCheckoutFormFields()
{
    $orderIncrementId = $this->getCheckout()->getLastRealOrderId();
    $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
    /* @var $api Mage_Paypal_Model_Api_Standard */
    $api = Mage::getModel('paypal/api_standard')->setConfigObject($this->getConfig());
    $api->setOrderId($orderIncrementId)
        **->setCurrencyCode($order->getOrderCurrencyCode())** // should be used getOrderCurrencyCode();
        //->setPaymentAction()
        ->setOrder($order)
        ->setNotifyUrl(Mage::getUrl('paypal/ipn/'))
        ->setReturnUrl(Mage::getUrl('paypal/standard/success'))
        ->setCancelUrl(Mage::getUrl('paypal/standard/cancel'));

    // export address
    $isOrderVirtual = $order->getIsVirtual();
    $address = $isOrderVirtual ? $order->getBillingAddress() : $order->getShippingAddress();
    if ($isOrderVirtual) {
        $api->setNoShipping(true);
    } elseif ($address->validate()) {
        $api->setAddress($address);
    }

    // add cart totals and line items
    $api->setPaypalCart(Mage::getModel('paypal/cart', array($order)))
        ->setIsLineItemsEnabled($this->_config->lineItemsEnabled)
    ;
    $api->setCartSummary($this->_getAggregatedCartSummary());
    $api->setLocale($api->getLocaleCode());
    $result = $api->getStandardCheckoutRequest();
    return $result;
}

事实证明,可以在每个商店视图上设置基础货币。但是,在管理端没有提供此选项。我必须更改system.xml

<label>Base Currency</label>
app/code/core/Mage/Directory/etc/system.xml

<label>Base Currency</label>
基础货币
我必须设置适当的值,以便从0更改为1

<show_in_store>1</show_in_store>
1
完成后,我甚至可以在商店视图中的“货币选项”下看到基础货币。现在一切都很好,一切都很顺利


不需要更改PHP代码或任何附加插件。

您确定这是必需的吗?感觉像是在Magento的某些设置中。Magento有很多怪癖。。他们不能在开箱即用的情况下正确处理国际货币,这很可笑,但这是我能找到的唯一解决问题的方法。你用的是什么版本?Magento版本