简体   繁体   English

购物车价格变动

[英]shopping cart price change

Say i have a Laptop for 600.00. 说我有600.00的笔记本电脑。 Say i change it to $650.00. 说我把它改成$ 650.00。 How do shopping carts handle that? 购物车如何处理? Like do they store the price in the cart or the item? 他们喜欢将价格存放在购物车或商品中吗? How do they make sure they get the price they wanted but not bill the customer the new change without asking them? 他们如何确保他们获得他们想要的价格,而不是在不问他们的情况下向客户收取新的变更费用? Or do most store them in both? 或者大多数将它们存储在两者中?

I was thinking maybe i could store it in both. 我想也许我可以将它存储在两者中。 So if the current price is over the cart price for a item, don't remove it/bill them from their cart. 因此,如果当前价格超过商品的购物车价格,请不要将其从购物车中移除/开票。 Then after, tell them what was billed/email a receipt for the items that didn't change that was billed(say they had more then one item) and remove it from the cart. 之后,告诉他们收取的费用/通过电子邮件发送收据,以确定未更改的项目(比如他们有多个项目)并将其从购物车中删除。 For the items that did change, say something like "Items left in cart due to price change, please check if you still want to buy the items at the new price." 对于确实发生变化的商品,请说出“由于价格变动而在购物车中留下的商品,请检查您是否仍想以新价格购买商品”。 So leave the items that changed in the cart but update the price in the cart. 因此,请保留购物车中更改的商品,但要更新购物车中的价格。

Thats my idea on how to do it. 多数民众赞成我的想法如何做到这一点。 I don't think the language should matter. 我不认为语言应该重要。 Guess this is more of a logical type question. 猜猜这更像是一个逻辑类型的问题。 Do most shopping carts do it this way or is there a better way? 大多数购物车是这样做的还是有更好的方法?

Simple shopping carts are just arrays of products that are maintained through sessions and cookies. 简单的购物车只是通过会话和cookie维护的产品阵列。 You can do anything you want. 你可以做任何你想做的事。 Just make sure users can't do anything they want such as change prices through the url. 只需确保用户无法做任何他们想做的事情,例如通过网址更改价格。 But most of all make it very, very, very easy for the user to checkout. 但最重要的是使用户非常,非常非常容易结账。

Most developers will create an array with product objects so if any changes are made to a product shopping carts will reflect this change. 大多数开发人员将使用产品对象创建一个数组,因此如果对产品进行任何更改,购物车将反映此更改。 However, if you change your prices then obvious you will have a problem if a user clicks on on price but then you change it and the uses doesn't see this change until after they paid or become confused why the price went up mid shopping experience. 但是,如果您更改价格然后显而易见,如果用户点击价格然后您更改它并且用户在他们支付或变得困惑之后看不到这种变化,那么在购物体验中价格会上涨时会出现问题。

In terms of maintaining the line item if you have users sign in before they can add things to a cart then you don't need to worry about creating a cookie/session to store the array of the line items until they do checkout and the line items are saved with their information for later reference. 在维护订单项方面,如果您有用户在将商品添加到购物车之前登录,那么您无需担心创建Cookie /会话来存储订单项的数组,直到他们执行结帐和行项目与其信息一起保存,以供日后参考。

In this case what you will want to do is create a line item which is associated to the object so you can get all the products information but at the same time store the price in that actual LineItem model so if you do update your price it will not affect shoppers mid buying experience. 在这种情况下,您要做的是创建一个与该对象关联的行项目,以便您可以获取所有产品信息,但同时将价格存储在该实际的LineItem模型中,这样如果您确实更新了价格,它将会不影响购物者中期购买体验。

And if you want users to pay higher prices because you change your mind and want to use the line item model you can just do what is sated in the last paragraph and check the price right before a user decides to checkout. 如果您希望用户支付更高的价格,因为您改变主意并希望使用订单项模型,您可以执行最后一段中的内容并在用户决定结帐之前检查价格。 If it is different then let them no that this product is now x amount to purchase and don't forget to apologize. 如果它不同,那就让他们不要说这个产品现在是购买的数量,不要忘记道歉。

The short answer, it all depends on how it was coded. 简短的回答,一切都取决于它的编码方式。

I assume the transaction that you are talking about is in process. 我假设你正在谈论的交易正在进行中。 If the price changes after the user completes the transaction, then it would be considered a "Bad Thing" in the terms of customer service, and may potentially be illegal in the eyes of your payments processor. 如果在用户完成交易后价格发生变化,那么在客户服务方面它将被视为“坏事”,并且在您的支付处理器眼中可能是非法的。

I like your idea of comparing the price in the cart vs the newest price. 我喜欢你比较购物车价格和最新价格的想法。 However if the user can change the value of the price of an item in the request to view the cart, it could cause many problems with what they actually get charged. 但是,如果用户可以更改请求中项目的价格值以查看购物车,则可能会导致许多实际收费问题。 For example, if the user changed the price of the laptop to $1200, and in your code you reduced the value in their cart by the difference, they could get that laptop for $0, which would be a "Bad Thing". 例如,如果用户将笔记本电脑的价格改为1200美元,并且在您的代码中,您通过差异减少了购物车中的价值,他们可以将该笔记本电脑的价格降至0美元,这将是一个“坏事”。

$1200 - User Input $600 - Actual Price -$600 - Adjustment against price $0 - price customer is charged? 1200美元 - 用户输入600美元 - 实际价格 - 600美元 - 价格调整0美元 - 客户收费价格?

Another example would be if you make the price of the item a value that the user can edit, and they are a malicious user, they could potentially change the price to -$600.00, which again would be a "Bad Thing". 另一个例子是,如果您将项目的价格设为用户可以编辑的值,并且他们是恶意用户,他们可能会将价格更改为 - $ 600.00,这又是一个“坏事”。

The more secure way to do it would be to store the item ID of the item in the cart in the link to view the cart, then retrieve/update the price of the item in the cart every time the properties (total, etc) of the cart are requested. 更安全的方法是将项目的商品ID存储在链接中的购物车中以查看购物车,然后每次检查/更新购物车中商品的价格(总等)请求购物车。 That way if a malicious user tried the plus or minus trick, they would just get a message that the price has been updated to the "current price". 这样,如果恶意用户尝试了加号或减号技巧,他们只会收到价格已更新为“当前价格”的消息。

The OWASP site has some open source security tools that can help test your code against situations where the user tries to high jack a shopping cart. OWASP网站有一些开源安全工具,可以帮助测试您的代码,以防止用户试图高举购物车。 Their address is http://www.owasp.org 他们的地址是http://www.owasp.org

If the cart simply contains a reference to the item (such as the id/primary key), you don't need to store the price in two places at all. 如果购物车只包含对商品的引用(例如id /主键),则根本不需要将价格存储在两个地方。 You simply load the objects from the cart when you need them, and prices will automatically reflect the change. 您只需在需要时从购物车中加载对象,价格将自动反映更改。 In most cases, the changes will be infrequent enough that it is not a big deal from a user perspective. 在大多数情况下,这些变化很少,从用户的角度来看并不是什么大不了的事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM