广州传奇网络
地址:广州市天河区东圃大马路富华楼C座
电话:13808825895
QQ:1564443073
首先在\admin\templates\里面找到 属性与规格 的位置 发现他调用了{$goods_attr_html}这个页面,
这个函数的定义在\admin\goods.php 的第444行
$smarty->assign('goods_attr_html', build_attr_html($goods['goods_type'], $goods['goods_id']));
然后找build_attr_html这个函数,在\admin\includes\lib_goods.php的675行
在if语句中加上
|| $val['attr_type'] == 3
这样就可以在\admin\templates\ 里面的55行
加入
input type="radio" name="attr_type" value="3" {if $attr.attr_type eq 3} checked="true" {/if} // 自定义属性
然后在添加属性的时候选中这项。
下来在前台即\themes\default\goods.dwt搜”判断属性是复选还是单选“,在循环里加入
代码如下:
<!--{elseif $spec.attr_type eq 3}-->
<!-- {foreach from=$spec.values item=value key=key} -->
<label for="spec_value_{$value.id}">
<input type='text' name="spec_{$spec_key}" id="{$value.id}" onclick="changePrice()" />
{$value.label} [{if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if} {$value.format_price|abs}] </label>
<!-- {/foreach} -->
<input type="hidden" name="spec_list" value="{$key}" />
代码如下:
$html .= ($val['attr_type'] == 1 || $val['attr_type'] == 2) ?
$GLOBALS['_LANG']['spec_price'].' <input type="text" name="attr_price_list[]" value="' . $val['attr_price'] . '" size="5" maxlength="10" />' :
' <input type="hidden" name="attr_price_list[]" value="0" />';
代码如下:
$attr_value = $_POST['attr_value_list'][$key];
$attr_price = $_POST['attr_price_list'][$key];
代码如下:
if ($info['sign'] == 'insert')
{
$sql = "INSERT INTO " .$ecs->table('goods_attr'). " (attr_id, goods_id, attr_value, attr_price,attr_itype)".
"VALUES ('$attr_id', '$goods_id', '$attr_value', '$info[attr_price]','$attr_itype')";
}
代码如下:
function getSelectedAttributes(formBuy)
{
var spec_arr = new Array( new Array(),new Array());
var j = 0;
var ki = 0;
for (i = 0; i < formBuy.elements.length; i ++ )
{
var prefix = formBuy.elements[i].name.substr(0, 5);
if (prefix == 'spec_' && (
((formBuy.elements[i].type == 'radio' || formBuy.elements[i].type == 'checkbox') && formBuy.elements[i].checked) ||
formBuy.elements[i].tagName == 'SELECT'))
{
spec_arr[0][j] = formBuy.elements[i].value;
j++ ;
}
if (prefix == 'spec_' && formBuy.elements[i].type == 'text' )
{
spec_arr[0][j] = formBuy.elements[i].id;
spec_arr[1][ki] = formBuy.elements[i].value;
j ++;
ki ++;
}
}
return spec_arr;
}
代码如下:
function get_goods_attr_info2($arr,$desc)
{
$attr = '';
if (!empty($arr))
{
$fmt = "%s:%s %s\n";
$fmt2 = "%s:%s[%s]\n";
$sql = "SELECT a.attr_name, ga.attr_value, ga.attr_price, ga.attr_itype ".
"FROM ".$GLOBALS['ecs']->table('goods_attr')." AS ga, ".
$GLOBALS['ecs']->table('attribute')." AS a ".
"WHERE " .db_create_in($arr, 'ga.goods_attr_id')." AND a.attr_id = ga.attr_id";
$res = $GLOBALS['db']->query($sql);
$i=0;
while ($row = $GLOBALS['db']->fetchRow($res))
{
if($row['attr_itype']==3)
{
$attr_price = round(floatval($row['attr_price']), 2);
$attr .= sprintf($fmt, $row['attr_name'], $row['attr_value'], $desc[$i]);
$i++;
}
else
{
$attr_price = round(floatval($row['attr_price']), 2);
$attr .= sprintf($fmt2, $row['attr_name'], $row['attr_value'],$attr_price);
}
}
$attr = str_replace('[0]', '', $attr);
}
return $attr;
}