【问题标题】:Shipping methods are not displayed accordingly in Magento 1.8Magento 1.8 中未相应显示运输方式
【发布时间】:2014-06-14 16:44:26
【问题描述】:

如何根据我在排序订单输入字段中设置的订单号显示我的运输方式列表?

我已在后台设置了每种送货方式的排序顺序,但没有相应显示。

例如,在我的后台,我有这些运输方式,

Method Name: bestway
Sort Order: 1

Method Name: Free
Sort Order: 2

Method Name: Chronopost
Sort Order: 3

但是它们在frontend\argenties\default\template\checkout/cart/shipping.phtml中并没有按这个顺序显示

    <?php
    $methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
    $shipping = array();
    foreach($methods as $_ccode => $_carrier):
        if($_methods = $_carrier->getAllowedMethods()):
            if(!$_title = Mage::getStoreConfig("carriers/$_ccode/title"))
                $_title = $_ccode;

            foreach($_methods as $_mcode => $_method):
                $_code = $_ccode . '_' . $_mcode;
                $shipping[$_code] = array('title' => $_method,'carrier' => $_title);
            ?>

            <li><input type="radio" name="estimate_method" value="<?php echo $_code;?>" id="s_method_<?php echo $_code ?>"<?php if($_code === $this->getAddressShippingMethod()) echo ' checked="checked"' ?>> <span class="item-text-shipping-method"><?php echo $_title;?></span></li>

            <?php endforeach;?>

        <?php endif;?>
    <?php endforeach;?>

结果,

Method Name: Free
Method Name: bestway
Method Name: Chronopost

Method Name: bestway 应该在列表的顶部,但它总是被降到第二个。为什么?知道如何解决吗?

【问题讨论】:

    标签: magento sorting shipping


    【解决方案1】:

    请注意以下事实:

    1. 自定义配送方式(也称为离线配送)将始终显示在实时配送方式之前。

    2. 每个承运人内的运输方式将按价格顺序显示(从最低到最高)。

    【讨论】:

      【解决方案2】:
      <?php
      foreach ($_shippingRateGroups as $code => $_rates):?>
              <?php foreach ($_rates as $_rate): ?>
                  <li>
                          <input name="estimate_method" type="radio" value="<?php echo $this->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio" />
                          <span class="item-text-shipping-method">
                              <?php echo $this->getCarrierName($code);?>
                          </span>
                  </li>
              <?php endforeach; ?>
      

      试试这个代码,我在 base/default/checkout/cart/shipping.phtml 文件中提醒了这个代码

      【讨论】:

      • 此代码有时无法显示运输方式。我必须重新加载它才能看到它们。
      【解决方案3】:

      运输方式是按价格排序的,当都是一样的价格时,不看其他字段决定哪个先到。

      我遇到了类似的问题,我的送货方式是一个固定价格,所以我在Mage/Shipping/Model/Rate/Results.php 文件中添加了额外的排序标准,特别是sortRatesByPrice() 函数。

      如果您想对核心文件进行更改,请务必将它们复制到您的本地池中。

      【讨论】:

        猜你喜欢
        • 2016-06-03
        • 1970-01-01
        • 2015-01-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-01
        • 2015-08-14
        • 2013-01-04
        相关资源
        最近更新 更多