3

我已经启用了两种运输方式。1. 表率 2. 免费送货

我只需要显示一种运输方式,还需要启用两种运输方式。我在 app\code\core\Mage\Checkout\Block\Onepage\Shipping\Method\Available.php 中自定义了代码

if (!empty($groups)) {
            $ratesFilter = new Varien_Filter_Object_Grid();
            $ratesFilter->addFilter(Mage::app()->getStore()->getPriceFilter(), 'price');

            $custom = array();
            $k=0;
            foreach ($groups as $code => $groupItems) {
                $custom['shippingmethod'][$k] = $code;
                $k++;
            }

            $check = array('tablerate','freeshipping');

            if(in_array($check,$custom)){

                foreach ($groups as $code => $groupItems) {
                    if($code == 'tablerate')
                        $groups[$code] = $ratesFilter->filter($groupItems);
                }
            } else {
                foreach ($groups as $code => $groupItems) {
                    $groups[$code] = $ratesFilter->filter($groupItems);
                }
            }
        }

但它没有给我运输方式的价格。有没有其他解决方案?

4

1 回答 1

5

您可以在前端模板中自定义此功能。您将不得不更改 app/design/frontend/_your_package_/_your_theme_/template/checkout/onepage/shipping_method/available.phtml

我想您只想显示免费送货(如果有)。当免费送货不可用时,无论如何都不应该显示。

原始代码:

<dl class="sp-methods">
<?php $shippingCodePrice = array(); ?>

新代码:

<dl class="sp-methods">
<?php
    $showFreeShipping = false;
    $_shippingRateGroupsReduced = array();
    foreach ($_shippingRateGroups as $code => $_rates) {
        if(strstr($code, 'freeshipping')) {
            $showFreeShipping = true;
            $_shippingRateGroupsReduced[$code] = $_shippingRateGroups[$code];
        }
    }

    if($showFreeShipping) {
        $_shippingRateGroups = $_shippingRateGroupsReduced;
    }

?>
<?php $shippingCodePrice = array(); ?>
于 2013-06-26T16:46:57.860 回答