如果满足 X,则增加购物车成本
因此,我们在使用基于愚蠢的物品/产品的运输时遇到了问题,又名 用户将产品添加到购物车 (FedEx/USPS) 并添加费用 到运输。如果购物车中有 X 件商品,则费率会增加 通过信封运送的产品 通过盒子运送。这 需额外支付 20 美元服务费。我想附加一个额外的 如果满足 X 件商品,购物车费用为 20 美元,但添加此商品时遇到问题 到会话信息(并保留它)。使用这段代码,我可以添加 额外的运费:
# %install_dir%/catalog/checkout_shipping.php
$_SESSION['cart']->total = $_SESSION['cart']->total + 20;
var_export($cart);
这不会反映在我当前的购物车模块/侧栏中 不过价格。帮助将不胜感激!
So we have an issue with using a silly item/product based shipping, aka
the user adds a product to the cart (FedEx/USPS) and the cost is added
to shipping. If X amount of items are in teh cart, the rate increases due
to products being shipped via envelope to being shipped via box. This
incurs an additional 20$ service charge. I would like to append an additional
20$ to cart costs if X items are met, but am having an issue with adding this
to the session information (and having it stick). Using this code, I can add
an additional cost to shipping:
# %install_dir%/catalog/checkout_shipping.php
$_SESSION['cart']->total = $_SESSION['cart']->total + 20;
var_export($cart);
This does not reflect in my shopping cart module/sidebar with he current
price though. Help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这些行之前的脚本中是否有“session_start()”?
另外,您可能不想将其正确计入总数。我将其放入与运输相关的变量中,并将其添加到运行总计中。这样,如果您已经添加过一次,就可以确保不会再次添加!喜欢:
另外... # 已弃用,请使用 // 或 /* !
Is there a "session_start()" somewhere in this script prior to these lines?
Also, you might not want to put it right in the total. I'd put it in a shipping related variable, as well as add it to the running total. That way you can make sure you don't add it again if you've already done it once! Like:
Also... # is deprecated, use // or /* !