【问题标题】:"Please specify a shipping method." while making order programmatically magento“请指定运输方式。”在以编程方式下订单时 magento
【发布时间】:2016-11-14 08:29:52
【问题描述】:

我在使用多运输结帐时以编程方式在 magento 中构建订单。一切都很好,我被困在我使用两种运输方式的地方

统一费率

矩阵率

当我选择 flatrate 时,订单正在创建并且一切都很好,但是当我选择 matrixrate 时,它​​不起作用给我错误

请指定送货方式。

因为这个功能

getShippingRateByCode

returns false 这里是这个函数中的代码

public function getShippingRateByCode($code)
{
    foreach ($this->getShippingRatesCollection() as $rate) {
        if ($rate->getCode() == $code) {
            return $rate;
        }
    }
    return false;
}

我发现在 $code 中该方法是 matrixrate 但在 $rate->getCode() 中该方法是 flatrate 这就是 if 不起作用的原因。 你能告诉我为什么即使我选择了 matrixrate,$rate->getCode() 也有 flatrate。

【问题讨论】:

    标签: magento magento-1.9


    【解决方案1】:

    我添加了一个单一的运输方式“test_methode”,如下所示:

    $shippingAddress = $quote->getShippingAddress()->addData($shipingAddress);
    $shippingAddress->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('test_methode');
    

    也许这对你有帮助。

    【讨论】:

      猜你喜欢
      • 2016-08-11
      • 1970-01-01
      • 2013-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多