yuncart商品详情页数据格式 - 商品规格

4个数组:

$this->data["specs"] = $specs;
$this->data["thespecs"]     = $thespecs;
$this->data["itemspecs"] = $itemspecs;
$this->data['productstr'] = json_encode($products);

衣服有2个规格,颜色和尺码

dump($this->data["specs"]);

显示如下:

Array
(
    [1] => Array
        (
            [specid] => 1
            [name] => 颜色
            [memo] => 服装
            [type] => pic
        )

    [2] => Array
        (
            [specid] => 2
            [name] => 尺码
            [memo] => 服装
            [type] => text
        )

)

$thespecs[$spec['specid']][] = $spec['specvalid'];,规格ID对应的规格值ID。

dump($this->data["thespecs"]);

显示如下:

Array
(
    [1] => Array
        (
            [0] => 36
            [1] => 31
            [2] => 5
            [3] => 31
        )

    [2] => Array
        (
            [0] => 8
            [1] => 8
            [2] => 10
            [3] => 9
        )

)

dump($this->data["itemspecs"]);

显示如下:

Array
(
    [1] => Array
        (
            [text] => Array
                (
                    [5] => 黑色
                    [31] => 白色
                    [36] => 蓝色
                )

            [pic] => Array
                (
                    [1] => 
                    [2] => 
                    [3] => 
                    [4] => 
                    [5] => http://demo.yuncart.com/uploads//2012/05/08/20120508145603_308v_cfc2ca1a.jpg
                    [6] => 
                    [7] => 
                    [31] => http://demo.yuncart.com/uploads//2012/05/08/20120508145611_QCRB_2b3877c6.jpg
                    [32] => 
                    [33] => 
                    [34] => 
                    [35] => 
                    [36] => http://demo.yuncart.com/uploads//2012/05/08/20120508145558_Yxkp_5683169c.jpg
                    [37] => 
                    [38] => 
                )

            [sel] => Array
                (
                    [0] => 5
                    [1] => 31
                    [2] => 36
                )

        )

    [2] => Array
        (
            [text] => Array
                (
                    [8] => S
                    [9] => M
                    [10] => L
                )

            [sel] => Array
                (
                    [0] => 8
                    [1] => 9
                    [2] => 10
                )

        )

)

货品数组:$products[$spec['productid']]['spec'][$spec['specid']] = $spec['specvalid'];

$this->data['productstr']的值是json_encode($products)的JSON字符串(点击规格时,Javascript设置规格可选不可选用到),$products的结构如下:

Array
(
    [67] => Array
        (
            [productid] => 67
            [itemid] => 8
            [bn] => C3NC405210201
            [inventory] => 20
            [price] => 110.00
            [volume] => 0
            [spec] => Array
                (
                    [1] => 36
                    [2] => 8
                )

        )

    [68] => Array
        (
            [productid] => 68
            [itemid] => 8
            [bn] => C3NC405210202
            [inventory] => 20
            [price] => 110.00
            [volume] => 0
            [spec] => Array
                (
                    [1] => 31
                    [2] => 8
                )

        )

    [69] => Array
        (
            [productid] => 69
            [itemid] => 8
            [bn] => C3NC405210203
            [inventory] => 20
            [price] => 110.00
            [volume] => 0
            [spec] => Array
                (
                    [1] => 5
                    [2] => 10
                )

        )

    [70] => Array
        (
            [productid] => 70
            [itemid] => 8
            [bn] => C3NC405210204
            [inventory] => 20
            [price] => 110.00
            [volume] => 0
            [spec] => Array
                (
                    [1] => 31
                    [2] => 9
                )

        )

)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值