Codeigniter购物车类-产品选项的额外价格 [英] Codeigniter Cart Class - additional price for product options

查看:71
本文介绍了Codeigniter购物车类-产品选项的额外价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Codeigniter购物车类的产品选项中添加价格值。例如:T恤价格为$ 10.00,但XXL尺寸额外为$ 2.00。

Is it possible to add price values to product options in the Codeigniter Cart Class. For example: T-shirt price is $10.00, but the XXL size is an extra $2.00.

$data = array(
           'id'      => 'abc',
           'qty'     => 1,
           'price'   => 10.00,
           'name'    => 'T-Shirt',
           'options' => array('Size' => 'XXL') // Where would you add $2.00 for XXL?
        );

$this->cart->insert($data);


推荐答案

这就是我们构建自己的购物车的原因之一和订单管理系统不同于CI的原始系统。

That's one of the reasons why we built our own cart and order management system apart from CI's original one.

恕我直言,更好的方法是扩展或重建CI的购物车类,以便直接从数据库结果中注入产品和选项。这样一来,您始终可以跟踪价格的计算方式:从ericofsac的答案,为什么定价为12而不是10以及在发售时收取了多少费用。

The better way imho is to extend or rebuild CI's cart Class in order to inject product and options straight from db results. This way you can always track down how the price was calculated : from ericofsac's answer, why it is priced at 12 not 10 and how much the option was charged at sale's time.

您还可以简化从购物车数据到订单的记录界面的实现,但这是另一点。

You can also ease implementation of recording interfaces from your cart data to your order, but that's another point.

这篇关于Codeigniter购物车类-产品选项的额外价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆