ecshop里面实体商品,比如手机,支持分类属性价格,比如给手机分类设置了一个颜色属性,然后又可选的颜色值,然后三星手机如果输入分类的话,他就有几种颜色可选并可以分别设置价格,比如白色1100 黑色1000
但是系统虚拟商品部分却不支持分类属性价格,我们来稍微的改一下使其支持,这样,比如你买移动充值卡不用个面额一种商品,而是一个商品设置几个面额属性价格就ok了
黑色文字是原来代码 绿色是新添代码 灰色和红色是修改代码(红色是)
共修改1个程序文件 4个模板文件
admin/virtual_card.php文件
第一处:
$link[] = array('text'=>$_LANG['go_back'],'href'=>'virtual_card.php?act=list');
sys_msg($_LANG['replenish_no_get_goods_name'],1, $link);
}
}
//获得商品属性列表
$sql = "SELECT p.product_id, g.attr_value, g.attr_id FROM ".$ecs->table('products')." p,".$ecs->table('goods_attr')." g WHERE p.goods_id='".$_REQUEST['goods_id']."' AND p.goods_attr = g.goods_attr_id";
$attrlist = $db->GetAll($sql);
if(!empty($attrlist)){
$attrname = $db->getOne("SELECT attr_name FROM ".$ecs->table('attribute')." WHERE attr_id = ".$attrlist[0]['attr_id']);
}
$card = array('goods_id'=>$_REQUEST['goods_id'],'goods_name'=>$goods_name, 'end_date'=>date('Y-m-d', strtotime('+1 year')));
$smarty->assign('card', $card);
$smarty->assign('attrname', $attrname); //传入属性名称
$smarty->assign('attrlist', $attrlist); //传入属性列表
$smarty->assign('ur_here', $_LANG['replenish']);
第二处
$end_date = strtotime($_POST['end_dateYear'] . "-" . $_POST['end_dateMonth'] . "-" . $_POST['end_dateDay']);
$add_date = gmtime();
$sql = "INSERT INTO ".$ecs->table('virtual_card')." (goods_id, product_id, card_sn, card_password, end_date, add_date, crc32) ".
"VALUES ('$_POST[goods_id]', '$_POST[product_id]', '$coded_card_sn', '$coded_card_password', '$end_date', '$add_date', '" . crc32(AUTH_KEY) . "')";
$db->query($sql);
第三处
$list = get_replenish_list();
//获得属性名称
$attrname = $db->getOne("SELECT attr_name FROM ".$ecs->table('goods')."g, ".$ecs->table('attribute')." a WHERE g.goods_type = a.cat_id AND g.goods_id ='$_REQUEST[goods_id]'");
//获得属性数组
$sql = "SELECT p.product_id, g.attr_value, g.attr_id FROM ".$ecs->table('products')." p,".$ecs->table('goods_attr')." g WHERE p.goods_id='".$_REQUEST['goods_id']."' AND p.goods_attr = g.goods_attr_id";
$attrlists = $db->GetAll($sql);
if(!empty($attrlists)){
foreach ($attrlists as $vo){
$attrlist[$vo['product_id']] = $vo['attr_value'];
}
}
$smarty->assign('attrname', $attrname); //传入属性名称
$smarty->assign('attrlist', $attrlist); //传入属性列表
$smarty->assign('card_list', $list['item']);
第四处
admin_priv('virualcard');
//获得商品属性列表
$sql = "SELECT p.product_id, g.attr_value, g.attr_id FROM ".$ecs->table('products')." p,".$ecs->table('goods_attr')." g WHERE p.goods_id='".$_REQUEST['goods_id']."' AND p.goods_attr = g.goods_attr_id";
$attrlist = $db->GetAll($sql);
if(!empty($attrlist)){
$attrname = $db->getOne("SELECT attr_name FROM ".$ecs->table('attribute')." WHERE attr_id = ".$attrlist[0]['attr_id']);
}
$smarty->assign('attrname', $attrname); //传入属性名称
$smarty->assign('attrlist', $attrlist); //传入属性列表
$smarty->assign('ur_here', $_LANG['batch_card_add']);
第五处
$rec[$i]['end_date'] = $row[2];
break;
}
$i++;
}
if($_POST['product_id'] != null){
$product_id = explode('|', $_POST['product_id']);
$product_id[2] = "<th>$product_id[2]</th>";
$product_id[1] = "<td>$product_id[1]</td>";
$product_id[0] = '<input type="hidden" value="'.$product_id[0].'" />';
$smarty->assign('product_id',$product_id);
}
$smarty->assign('ur_here', $_LANG['batch_card_add']);
第六处:
foreach ($_POST['checked'] as $key)
{
$rec['product_id'] = $_POST['product_id'];
$rec['card_sn'] = encrypt($_POST['card_sn'][$key]);
admin/templeate/batch_card_info.htm文件
约第10行
<td><input type="text" maxlength="60" size="6" value="," />{$lang.require_field}</td>
</tr>
{if $attrlist != null}
<tr>
<td>{$attrname}:</td>
<td><select>
{foreach item=item from=$attrlist}
<option value="{$item.product_id}|{$item.attr_value}|{$attrname}">{$item.attr_value}</option>
{/foreach}
</select>
</td>
</tr>
{/if}
<tr>
<td>{$lang.uploadfile}</td>
admin/templeate/batch_card_confirm.htm文件
约第9行
<th><input type="checkbox" checked />{$lang.lab_card_id}</th>
{$product_id[2]}
<th>{$lang.lab_card_sn}</th>
<th>{$lang.lab_card_password}</th>
<th>{$lang.lab_end_date}</th>
</tr>
{foreach from=$list key=key item=card}
<tr>
<td><input type="checkbox" value="{$key}" checked /> {$key}</td>{$asdfd}
{$product_id[1]}
<td><input type="text" value="{$card.card_sn}" size="15" /></td>
<td><input type="text" value="{$card.card_password}" size="15" /></td>
<td><input type="text" value="{$card.end_date}" size="15" /></td>
</tr>
{/foreach}
<tr>
<td colspan="6">
{$product_id[0]}
<input type="hidden" value="{$smarty.request.goods_id}" />
admin/templeate/replenish_info.htm文件
约第9行
<td>{$lang.lab_goods_name}</td>
<td><input type="text" maxlength="60" value="{$card.goods_name}" disabled="true" /></td>
</tr>
{if $attrlist != null}
<tr>
<td>{$attrname}:</td>
<td><select>
{foreach item=item from=$attrlist}
<option value="{$item.product_id}">{$item.attr_value}</option>
{/foreach}
</select>
</td>
</tr>
{/if}
<tr>
<td>{$lang.lab_card_sn}</td>
admin/templeate/replenish_list.htm文件
约第9行
<a href="javascript:listTable.sort('card_id'); ">{$lang.record_id}</a>{$sort_card_id}
</th>
{if $attrname != null}<th>{$attrname}</th>{/if}
<th><a href="javascript:listTable.sort('card_sn'); ">{$lang.lab_card_sn}</a>{$sort_card_sn}</th>
<th><a href="javascript:listTable.sort('card_password'); ">{$lang.lab_card_password}</a>{$sort_card_password}</th>
<th><a href="javascript:listTable.sort('end_date'); ">{$lang.lab_end_date}</a>{$sort_end_date}</th>
<th><a href="javascript:listTable.sort('is_saled'); ">{$lang.lab_is_saled}</a>{$sort_is_sold}</th>
<th><a href="javascript:listTable.sort('order_sn'); ">{$lang.lab_order_sn}</a>{$sort_order_sn}</th>
<th>{$lang.handler}</th>
</tr>
{foreach from=$card_list item=card}
<tr>
<td><input value="{$card.card_id}" type="checkbox">{$card.card_id}</td>
{if $attrname != null}<td><span>{$attrlist[$card.product_id]}</span></td>{/if}
<td><span>{$card.card_sn}</span></td>
<td><span>{$card.card_password}</span></td>
现在全部修改完毕:
操作方法:(实例方法)
管理员进入后台 -》商品类型-》新建一个类型-》点属性列表-》添加属性-》(单选属性:从下面列表选择<列表里填写黑色、白色>)-》确认
虚拟商品列表-》选择一个卡-》编辑-》商品属性选项卡(选择刚才新建的那个类型)-》点击+ -》添加2个属性(黑色白色并设置价格)-》确认
虚拟商品列表-》选择第二步一样的卡-》货品列表(就出现刚才那2个属性,库存都为1)
虚拟商品列表-》选择第二步一样的卡-》补货 -》补货时会出现给哪个商品属性进行补货下拉框(给黑色补货哦还是白色补货)
虚拟商品列表-》选择第二步一样的卡-》批量补货-》也会出现给哪个商品属性进行补货的下拉框
虚拟商品列表-》选择第二步一样的卡-》查看虚拟卡信息-》就出列出对应的商品属性的虚拟码列表了(暂时没时间做属性值搜索了,有时间做了贴上来)