• 欢迎使用 天下第一网店
  • 设为首页】【加入收藏
主页 > ECShop > 功能设置 >

ecshop购物车中属性显示的常识

来源:www.china1store.com 作者:天下第一网店 发表于:2011-03-22 12:14  点击:
ecshop 电子商务系统中,可以在购买商品的时候,让属性在 ecshop购物车 中显示,而这一机制.是在增加购物车的时候,就进行处理了,而且通过字符串形式存储在cart表中的。具体的存储在

ecshop电子商务系统中,可以在购买商品的时候,让属性在ecshop购物车中显示,而这一机制.是在增加购物车的时候,就进行处理了,而且通过字符串形式存储在cart表中的。具体的存储在goods_attr字段中。 copyright china1store ^ d8dpI%eK/p*o0

    他是通过以下函数来处理商品属性的。 china1store.com

    function get_goods_attr_info($arr)
{
    $attr   = '';

copyright china1store ^ d8dpI%eK/p*o0

    if (!empty($arr))
    {
        $fmt = "%s:%s[%s] \n";

        $sql = "SELECT a.attr_name, ga.attr_value, ga.attr_price ".
                "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 order by a.sort_order asc";
  
        $res = $GLOBALS['db']->query($sql); www.china1store.com H4h.M)[ F0c1]*k0

        while ($row = $GLOBALS['db']->fetchRow($res))
        {
            $attr_price = round(floatval($row['attr_price']), 2);
            $attr .= sprintf($fmt, $row['attr_name'], $row['attr_value'], $attr_price);
        } www.china1store.cn ;SZ:JO.LHU]\

        $attr = str_replace('[0]', '', $attr);
    }

    return $attr;
}

    当然,你也可以让属性在购物车中按顺序排序显示,你只需要加入order by a.sort_order asc来控制就可以了。而在增加购物车函数中,function addto_cart($goods_id, $num = 1, $spec = array(), $parent = 0)通过调用 $goods_attr             = get_goods_attr_info($spec);函数,来获取对应属性的值。 独立网店试用 UB D;o/j1~8@a0~0

 

www.china1store.net N9nx0k M RG]+iR0

有帮助
(0)
0%
没帮助
(0)
0%