广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > ecshop如何把颜色和尺码后面的价格去掉

二次开发Ecshop二次开发

二次开发Ecshop二次开发

ecshop如何把颜色和尺码后面的价格去掉

 怎么样把颜色和尺码后面的价格去掉?

可以在lib_common.php的price_format()函数中加上
if($price==0) return '';
代码如下:
/**
* 格式化商品价格
*
* @access  public
* @param   float   $price  商品价格
* @return  string
*/
function price_format($price, $change_price = true)
{
    if($price==0) return '';
        if ($change_price && defined('ECS_ADMIN') === false)
    {
        switch ($GLOBALS['_CFG']['price_format'])
        {
            case 0:
                $price = number_format($price, 2, '.', '');
                break;
            case 1: // 保留不为 0 的尾数
                $price = preg_replace('/(.*)(\\.)([0-9]*?)0+$/', '\1\2\3', number_format($price, 2, '.', ''));

                if (substr($price, -1) == '.')
                {
                    $price = substr($price, 0, -1);
                }
                break;
            case 2: // 不四舍五入,保留1位
                $price = substr(number_format($price, 2, '.', ''), 0, -1);
                break;
            case 3: // 直接取整
                $price = intval($price);
                break;
            case 4: // 四舍五入,保留 1 位
                $price = number_format($price, 1, '.', '');
                break;
            case 5: // 先四舍五入,不保留小数
                $price = round($price);
                break;
        }
    }
    else
    {
        $price = number_format($price, 2, '.', '');
    }

    return sprintf($GLOBALS['_CFG']['currency_format'], $price);
}

这样做还是去不掉[]
还需要修改goods.dwt
<!-- {* 判断属性是复选还是单选 *} -->
                    <!-- {if $spec.attr_type eq 1} -->
                      <!-- {if $cfg.goodsattr_style eq 1} -->
                        <!-- {foreach from=$spec.values item=value key=key} -->
                        <label for="spec_value_{$value.id}">
                        <input type="radio" name="spec_{$spec_key}" value="{$value.id}" id="spec_value_{$value.id}" {if $key eq 0}checked{/if} />
                        {$value.label}{if $value.price neq 0} [{if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if} {$value.format_price|abs}]{/if} </label><br />
                        <!-- {/foreach} -->
                        <input type="hidden" name="spec_list" value="{$key}" />
                        <!-- {else} -->
                        <select name="spec_{$spec_key}">
                          <!-- {foreach from=$spec.values item=value key=key} -->
                          <option label="{$value.label}" value="{$value.id}">{$value.label} {if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if}{if $value.price neq 0}{$value.format_price}{/if}</option>
                          <!-- {/foreach} -->
                        </select>
                        <input type="hidden" name="spec_list" value="{$key}" />
                      <!-- {/if} -->
                    <!-- {else} -->
                      <!-- {foreach from=$spec.values item=value key=key} -->
                      <label for="spec_value_{$value.id}">
                      <input type="checkbox" name="spec_{$spec_key}" value="{$value.id}" id="spec_value_{$value.id}" />
                      {$value.label}{if $value.price neq 0} [{if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if} {$value.format_price|abs}]{/if} </label><br />
                      <!-- {/foreach} -->
                      <input type="hidden" name="spec_list" value="{$key}" />
                    <!-- {/if} -->
      </li>
      <!-- {/foreach} -->
      <!-- {* 结束循环可选属性 *} -->

 

ecshop插件   ecshop教程