1. 找到系统lib_goods.php文件,函数get_goods_properties。增加属性spe的值
即修改成:
foreach ($res AS $row) {
$row['attr_value'] =
str_replace("\n", '<br />', $row['attr_value']);
if ($row['attr_type'] == 0) {
$group =
(isset($groups[$row['attr_group']])) ? $groups[$row['attr_group']] :
$GLOBALS['_LANG']['goods_attr'];
$arr['pro'][$group][$row['attr_id']]['name']
= $row['attr_name'];
$arr['pro'][$group][$row['attr_id']]['value'] = $row['attr_value'];
} else {
$arr['spe'][$row['attr_id']]['attr_type'] = $row['attr_type'];
$arr['spe'][$row['attr_id']]['name'] = $row['attr_name'];
$arr['spe'][$row['attr_id']]['attr_index'] = $row['attr_index'];
$arr['spe'][$row['attr_id']]['values'][] = array(
'label' => $row['attr_value'],
'price' => $row['attr_price'],
'format_price' => price_format(abs($row['attr_price']), false),
'id' => $row['goods_attr_id']);
}
2,在ecshop 中判断
<!-- {if $spec.attr_index 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} onclick="changePrice()" />
{$value.label} [{if $value.price gt 0}{$lang.plus}{elseif $value.price lt
0}{$lang.minus}{/if} {$value.format_price|abs}] </label><br />
<!-- {/foreach}
-->
<input type="hidden" name="spec_list"
value="{$key}" />
<!-- {else} -->
<select name="spec_{$spec_key}"
onchange="changePrice()">
<!-- {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} -->
<!-- {/if} -->
<!-- {if $spec.attr_index eq 1} --> 就是主要判断部分。这样ecshop属性列表展示列表方式与单选按钮同时存在了。
|