Ubercart 2.0 - 允许小数数量的代码更改列表?
我正在为客户开发 Ubercart 2.0 项目。这是一家布料店。他们希望客户能够添加小数数量(或小数数量),例如 1.75 m。有没有人有一个可以实现此功能的代码更改的完整列表?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我正在为客户开发 Ubercart 2.0 项目。这是一家布料店。他们希望客户能够添加小数数量(或小数数量),例如 1.75 m。有没有人有一个可以实现此功能的代码更改的完整列表?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
我认为改变 ubercart 核心来实现你的意思是一个坏主意。当有安全修复程序时,您基本上注定自己无法更新/升级,并且可能其他一些模块会假设您正在使用整数,从而让位于难以跟踪的错误和 php 异常。
我没有像上一张海报那样进行广泛的搜索,但如果我必须自己实现您的需求,我会立即:
只是我的两分钱,但考虑到 ubercart 正在积极开发中,尽管最近退出了候选版本状态,但它仍然存在很多错误:您确实希望能够在修复程序出现时更新您的代码库。
编辑:只是为了强调上面的内容:自从我在不到一周前写下这个答案以来,已经发布了两个 UC 更新,其中一个修复了一个关键的安全问题...
希望这会有所帮助!
I think changing ubercart core to achieve what you mean is a bad idea. You are basically dooming yourself not to have the ability to update/upgrade when there are security fixes and probably some other module would assume you are using integer, giving way to difficult-to-track bugs and php exceptions.
I did not make an extensive search as the previous poster, but if I had to implement your need myself, off the top of my head I would:
Just my two cents, but consider that ubercart is in active development and - despite the recent exit from release candidate state - it still has plenty of bugs: you really want to be able to update your codebase when fixes come out.
EDIT: just to stress what above: since I wrote this answer less than a week ago, two UC updates have come out, of which one fixing a critical security issue...
Hope this helps!
当前的 Uberart(v 2.0)不允许其数量使用小数。
如果您在 Ubercart 论坛中搜索“十进制数量”、“数量分数”和“十进制数量”,您会得到一些结果。本文旨在概述可能对您安装的 Ubercart 系统进行的一些更改,以允许向您的购物车添加“小数数量”。
感谢莱尔和他的帖子回复,帮助我开始写这篇文章 。
添加到Ubercart Core?
我希望Ubercart开发者能够找到一种方法,将“小数数量”的能力实现到Ubercart Core。我希望这篇文档/文章将有助于实现这一目标!
数据库更改
将 Ubercart 更改为接受小数数量意味着某些表列的数据类型必须从 INTEGER 更改为 FLOAT(M,D)。 FLOAT 数据类型允许存储小数。这是来自 http://dev.mysql.com 的描述/doc/refman/5.0/en/numeric-types.html
下面是对表格进行的更改,以允许 2 位小数和 6 位总数字。应用以下数据库表更改不应影响现有数据,除非您的数量大于 6 位数字 - 在这种情况下您可以增加 M 值。
代码更改
为...
--
为...
--
为...
--
为...
--
--与...
--
为...
-
想法 其他更改
添加一些功能以允许选择是否允许某种产品类型/类别接受“小数数量”可能是一个好主意。也许在 uc_product_classes 表或 uc_products 表中添加布尔列(如“allow_frac_qty”)。当然,还会有更多的代码添加/更改来实现这一点。此外,uc_products 表中的“pkg_qty”列也可能需要更改
其他 Ubercart 论坛帖子
http://www.ubercart.org/forum/support/4651/use_fractions_quantity_15_yards
http://www.ubercart.org/forum/support/6074/decimal_quantities_items
http://www.ubercart.org/issue/6044/abilility_have_decimal_quantities
http://www.ubercart.org/forum/ideas_and_suggestions/3283/comma_values_quantity_field
The current Uberart (v 2.0) does not allow decimals for their quantities.
If you seach the Ubercart forums for “quantity as decimal”, “fractions for quantity”, and “decimal quantities” you get some hits. This article is an effort to outline some changes that may be made to your installed Ubercart system to allow addition of "fractional quantities" to your cart.
Thank you to Lyle and his post reply that helped me get started on this article.
Add To Ubercart Core?
I hope that the Ubercart developers can find a way to implement the ability for “fractional quantities” to Ubercart Core. I hope that this document / article will help make that happen!
Database Changes
Changing Ubercart to accept fractional quantities means the datatype of some table columns must be changed from INTEGER to FLOAT(M,D). The FLOAT data type allows for the decimal to be stored. Here is a description from http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
Below are the changes to the tables to be made to allow 2 decimal places and 6 total digits. Applying the following database table changes should not affect existing data, unless you have quantities greater than 6 digits – in which case you could increase the M value.
Code Changes
to...
--
to...
--
to...
--
to...
--
with...
--
to...
--
Thoughts - Additional Changes
It would probably be a good idea to add some functionality to allow a choice as to whether or not a certain product type / class is allowed to accept “fractional quantities”. Maybe the addition of a boolean column (like “allow_frac_qty”) in the uc_product_classes table or the uc_products table. Then of course, there would be more code additions / changes to allow for this. Also, the “pkg_qty” column in the uc_products table may also need to be changed
Other Ubercart Forum Posts
http://www.ubercart.org/forum/support/4651/use_fractions_quantity_15_yards
http://www.ubercart.org/forum/support/6074/decimal_quantities_items
http://www.ubercart.org/issue/6044/abiility_have_decimal_quantities
http://www.ubercart.org/forum/ideas_and_suggestions/3283/comma_values_quantity_field
以防万一有人需要 robnardo 消息中的解决方案,但要申请 drupal 7、ubercart 3 - 我在这里描述了在 Drupal 7、Ubercart 3.1 中对我有用的内容:
http://www.ubercart.org/project/uc_decimal_quantities#comment-68750
Just in case somebody needs the solution from robnardo's message but to apply for drupal 7, ubercart 3 - I described what had worked for me in Drupal 7, Ubercart 3.1 here:
http://www.ubercart.org/project/uc_decimal_quantities#comment-68750
麦克说得对。这种方法更加简单并且不易出现维护问题。
它还可以轻松支持任何类型的测量,使用 JavaScript 生成测量系统的下拉列表并在提交时进行转换。
mac's got it right. That approach is much simpler and less prone to maintenance problems.
It would also make it trivial to support any type of measurement using JavaScript to generate a drop down of measurement system and doing a conversion on submit.
我已经在 http://www.ubercart.org/issue/ 发布了我正在开发的模块6044/ability_have_decimal_quantities ...请留下您的反馈。
I have posted a module I am working on at http://www.ubercart.org/issue/6044/abiility_have_decimal_quantities ... Please leave your feedback.