ecshop 商品页面添加商品标签:
/*
@脚垫客户 需要给商品加属性。最简单粗暴的办法。后台调用加入。界面没有美化.
*/
goods.dwt
<ul class="quantity"> <h2>颜色:</h2> <div class="items"> <select id="cat_color" name="cat_color"> <option value="红色">红色</option> <option value="黑色">黑色</option> <option value="粉色">粉色</option> <option value="米色">米色</option> <option value="咖啡色">咖啡色</option> <option value="紫色">紫色</option> <option value="棕色">棕色</option> </select> </div> </ul> <ul class="quantity"> <h2>车型:</h2> <div class="items"> <span class="ui-number radius5"> <input class="num" name="catname" id="cat_name" type="text" size="5px" /> </span> <em>如:帕萨特,福克斯,s600</em> </div> </ul> </ul> <ul class="quantity"> <h2>年份:</h2> <div class="items"> <select id="cat_date" name="cat_date"> <option value="1993">1993</option><option value="1994">1994</option><option value="1995">1995</option><option value="1996">1996</option><option value="1997">1997</option><option value="1998">1998</option><option value="1999">1999</option><option value="2000">2000</option><option value="2001">2001</option><option value="2002">2002</option><option value="2003">2003</option><option value="2004">2004</option><option value="2005">2005</option><option value="2006">2006</option><option value="2007">2007</option><option value="2008">2008</option><option value="2009">2009</option><option value="2010">2010</option><option value="2011">2011</option><option value="2012">2012</option><option value="2013">2013</option><option value="2014">2014</option> <option value="2015">2015</option><option value="2016">2016</option> <option value="2017">2017</option><option value="2018">2018</option> <option value="2019">2019</option><option value="2020">2020</option> </select> </div> </ul> </ul> <ul class="quantity"> <h2>几座:</h2> <div class="items"> <select id="cat_size" name="cat_size"> <option value="2">2</option> <option value="4">4</option> <option value="5">5</option> <option value="7">7</option> <option value="8">8</option> </select> </div> </ul>
common.js
var catsize =document.getElementById("cat_size"); var catdate =document.getElementById("cat_date"); var catcolor =document.getElementById("catcolor"); var indes = catsize.selectedIndex; var index = catdate.selectedIndex; var indec = catdate.selectedIndex; goods.quick = quick; goods.catname = catname; goods.catsize = catsize.options[indes].value; goods.catdate = catdate.options[index].value; goods.catcolor = catcolor.options[indec].value;
flow.php
if (addto_cart($goods->goods_id, $goods->number, $goods->spec, $goods->parent, $goods->catname, $goods->catsize, $goods->catdate,$goods->catcolor))
/* 插入订单商品 */ $sql = "INSERT INTO " . $ecs->table('order_goods') . "( " . "order_id, goods_id, goods_name, goods_sn, product_id, goods_number, market_price, ". "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id,catname,catsize,catdate,catcolor) ". " SELECT '$new_order_id', goods_id, goods_name, goods_sn, product_id, goods_number, market_price, ". "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, goods_attr_id,catname,catsize,catdate,catcolor". " FROM " .$ecs->table('cart') . " WHERE session_id = '".SESS_ID."' AND rec_type = '$flow_type'";
lib_order.php
function addto_cart($goods_id, $num = 1, $spec = array(), $parent = 0,$catname = '',$catsize = '',$catdate='',$catcolor = '') , goods_price = '$goods_price',catname= '$catname' ,catsize= '$catsize' ,catdate= '$catdate' ,catcolor='$catcolor' $parent['parent_id'] = 0; $parent['catname'] = $catname; $parent['catsize'] = $catsize; $parent['catdate'] = $catdate; $parent['catcolor'] = $catcolor;
数据库 cart 表,建立字段:catname catsize catdate catcolor order_goods 表,建立字段 catname catsize catdate catcolor
后台:
order_info.htm
<td>{$goods.catdate}年的:{$goods.catname}.{$goods.catsize}座.{$goods.catcolor}.的座垫</td>
lang admin order.php
$_LANG['cat_name'] = '车备注'; $_LANG['catname'] = '车型'; $_LANG['catsize'] = '座'; $_LANG['catdate'] = '年'; $_LANG['catcolor'] = '颜色';
admin order.php
/* 取得订单商品及货品 */ $goods_list = array(); $goods_attr = array(); $sql = "SELECT o.*, IF(o.product_id > 0, p.product_number, g.goods_number) AS storage, o.goods_attr, o.catname,o.catsize,o.catdate,o.catcolor,g.suppliers_id, IFNULL(b.brand_name, '') AS brand_name, p.product_sn FROM " . $ecs->table('order_goods') . " AS o LEFT JOIN " . $ecs->table('products') . " AS p ON p.product_id = o.product_id LEFT JOIN " . $ecs->table('goods') . " AS g ON o.goods_id = g.goods_id LEFT JOIN " . $ecs->table('brand') . " AS b ON g.brand_id = b.brand_id WHERE o.order_id = '$order[order_id]'";
<td>{$goods.catdate}年的:{$goods.catname}.{$goods.catsize}座.{$goods.catcolor}.的座垫</td>