CodeIgniter 购物车 ID +选项
我遇到一种情况:
我的 CodeIgniter 购物车定制商店中有产品。 每个产品都有一个与其关联的 ID,但也有其选项(尺寸)。 这些尺寸都有不同的价格。 (我们谈论的是以不同打印尺寸出售的照片)。
由于 CI 购物车根据插入的产品 ID 进行更新、添加和删除,因此我无法插入一种具有 2 种不同尺寸的产品。 截至目前,我能想到的唯一解决方案是将 ID 作为 IMAGEID_OPTIONID 传递到购物车,以便它包含两个 ID。
然而,我想可能有一种更简单、更统一的方法来做到这一点? 或者一个比 ID 更好的解决方案,该 ID 本身不与任何特定内容关联,除非我爆炸它..?
I have a situation:
I have products that are in a CodeIgniter Cart custom store.
Each product has an ID associated with it, but also has options for it (sizes).
These sizes all have different prices. (We're talking about photos being sold at different print sizes).
Because CI Cart updates, adds and deletes based on the product ID inserted, I am not able to insert one product with 2 different sizes.
As of now, the only solution I can think of is to pass the ID to the cart as IMAGEID_OPTIONID
so that it contains both IDs.
However, I thought there might be an easier, more uniform way of doing this?
Or a better solution than an ID that isn't (on it's own) associated with anything specific unless i explode it..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近建立了一个有这些限制的网站。简而言之,您需要区分“产品”和“产品组”。将其视为管理最离散的数据单元。事实上,X 号中号衬衫实际上与 X 号大号衬衫不同……如果您的价格基于这些品质(当您考虑布料图案或颜色时,这就变得更加现实)。
所以无论如何,如果您有一个“groups”表、一个“product_groups”表和一个“products”表,您就可以保持所有这些想法不同。在产品表中,您可以包含“尺寸”和“颜色”列(以及您能想到的任何其他区别属性)以及“价格”列。或者,您可以更加核心并制作单独的定价表,将价格与独特的产品相匹配(如果您想跟踪历史价格和折扣,这将特别有用)。
然后,在您的购物车中,您可以简单地将product_ids附加到cart_ids并执行一些连接来确定该产品属于哪个“组”,该组中有哪些图片(或该产品存在哪些图片)等等。这不是一个简单的问题,但是遵循这个思路应该可以帮助您走上正确的道路。
最后一点:像这样跟踪独特的产品也使库存核算变得更加简单。
I recently built a site that had these constraints. In short, you'll want to create a distinction between "products" and "product groups". Think of it as managing the most discrete data units. In reality, shirt X sized medium is actually a different thing than shirt X sized large...doubly so if you have prices that are built on these qualities (this becomes more realistic when you consider cloth patterns or colors).
So anyway, if you have a "groups" table, a "product_groups" table, and a "products" table, you can keep all of these ideas distinct. On your products table, you can have columns for "size" and "color" (and any other distinguishing property you can think of) and a column for "price". Alternatively, you can go even more hardcore and make separate pricing tables that match up prices to unique products (this would be especially useful if you want to keep track of historical prices and discounts).
Then in your cart you can simply attach product_ids to cart_ids and perform a couple of joins to determine what "group" this product is a part of, what pictures are in that group (or exist for that product), and so on. It's not a simple problem, but following this line of thought should help get you on the right path.
One last point: keeping track of unique products like this also makes inventory accounting much, much more straightforward.