Codeigniter购物车中的小数? [英] Decimal quantity in Codeigniter's Shopping Cart?

查看:160
本文介绍了Codeigniter购物车中的小数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户希望能够购买小数位数的产品(例如1.5或3.5),请问有什么方法可以使codeigniter的Shopping Cart类能够处理此问题?

my client want to be able to buy products with decimal quantity, like 1.5 or 3.5, is there any way to codeigniter’s Shopping Cart class can handle this?

因为现在,如果我尝试放入和十进制数量表示去除逗号,例如,如果我键入1.5,则变为15.

Because right now if i try to put and decimal quantity it remover the comas, exemple, if i type 1.5, it goes as 15.

感谢关注

我通过转到"SYSTEM \ LIBRARIES \ CART.PHP"并更改了第161行来解决此问题:

从这里:

$items['qty'] = trim(preg_replace('/([^0-9])/i', '', $items['qty']));

对此:

$items['qty'] = trim(preg_replace('/([^0-9\.])/i', '', $items['qty']));

这样做,您可以在数量上加上小数.

Doing this, you can add decimals on quantity.

推荐答案

尝试扩展购物车库.在此处阅读更多信息:

Try extending the Cart library. Read more here:

http://forrst.com/posts/Extending_the_codeigniter_cart_library-NXv

这篇关于Codeigniter购物车中的小数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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