Magento Hide other shipping methods if shipping price is 0.00 without module

守給你的承諾、 提交于 2020-02-07 13:16:28

问题


I am trying to hide other shipping methods if the shipping price is 0.00 without using or creating a custom module.

The desired algorithm is:

  • If shipping price is 0.00 hide all other shipping methods

This is the Abstract.php I've tried:

<?php
public function getShippingRates()
    {
    $groups = parent::getShippingRates();
    $free = array();
    foreach($groups as $code => $_rates)
        {
        foreach($_rates as $_rate)
            {
            if (!$_rate->getPrice() > 0)
                {
                $free[$code] = $_rates;
                }
            }
        }

    if (!empty($free))
        {
        return $this->_rates = $free;
        }

    return $groups;
    }

来源:https://stackoverflow.com/questions/31875604/magento-hide-other-shipping-methods-if-shipping-price-is-0-00-without-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!