简体   繁体   English

Shopify - 在结账时验证购物车项目?

[英]Shopify - Validate cart items at checkout?

A product in my store (eg a fine art print) has a base price of £20 and it has multiple customizable options (size / framing) that are added as additional items to the cart (eg Small [£0] / Medium [+£10] / Large [+£20] or Unframed [£0] / Framed [+£10] ) I have to do it this way because some products have more than 3 variant options (Shopify only supports 3)我店里的一件产品(例如美术印刷品)的底价为 20 英镑,它有多个可定制的选项(尺寸/框架)作为附加项目添加到购物车(例如小 [£0] / 中 [+ £10] / Large [+£20] 或 Unframed [£0] / Framed [+£10] )我必须这样做,因为有些产品有超过 3 个变体选项(Shopify 仅支持 3 个)

These additional items that represent the customization options for the base product are added when the customer adds the base product to cart, but the additional products representing options are hidden to the customer in the cart.当客户将基本产品添加到购物车时,将添加这些代表基本产品定制选项的附加项目,但代表选项的附加产品在购物车中对客户隐藏。

At checkout however all is revealed, the base product appears with 2 additional items along with their additional prices.然而,在结帐时,所有内容都会显示,基本产品会显示 2 个附加项目及其附加价格。 Not ideal but OK!不理想但还可以!

However, it occurred to me that there's nothing stopping a tech-savvy nerd from grabbing the variant ID of the additional items and sending a POST request to /cart/update.js that removes them from the order during checkout.但是,我突然想到,没有什么可以阻止精通技术的书呆子获取额外商品的变体 ID 并向 /cart/update.js 发送 POST 请求,在结账时将它们从订单中删除。 The customer just reloads the checkout page and they've just halved the price they have to pay!客户只需重新加载结帐页面,他们就可以将必须支付的价格减半!

I need to prevent this from happening.我需要防止这种情况发生。 I don't suppose there's a way to validate all the items in the cart when the customer requests the checkout page?当客户请求结帐页面时,我不认为有一种方法可以验证购物车中的所有商品吗? If that's not possible, how do other Shopify stores get around this issue?如果这不可能,其他 Shopify 商店如何解决这个问题?

If you are on the Shopify Plus plan there are two things you can do:如果您使用的是 Shopify Plus 套餐,您可以做两件事:

  1. During checkout validation - use Script Editor to check the cart contents and if it's invalid, set the base product quantity and additional products to 0. This will prevent customers from checking out.在结帐验证期间 - 使用脚本编辑器检查购物车内容,如果无效,则将基本产品数量和附加产品设置为 0。这将阻止客户结帐。
  2. Post checkout validation - use Shopify Flow to cancel the order after it's placed and if it's invalid结帐后验证 - 使用Shopify Flow 在下订单后取消订单,如果订单无效

But that's a lot of development, especially when you are not familiar with it, it will be hard to go through and make it work as expected (covering all edge cases).但这需要大量开发,尤其是当您不熟悉它时,将很难通过 go 并使其按预期工作(涵盖所有边缘情况)。 It's possible to create a such script but analysis of all possible scenarios and writing a code for it will take some time.可以创建这样的脚本,但分析所有可能的场景并为其编写代码需要一些时间。 If I were you I would consider an app that creates bundles as a single item.如果我是你,我会考虑将捆绑包创建为单个项目的应用程序。 Adding such a bundle to the cart takes a few seconds to process as the app is making some admin API calls in the background but it solves your problem.将这样的捆绑包添加到购物车需要几秒钟的时间来处理,因为该应用程序正在后台进行一些管理 API 调用,但它解决了您的问题。 I cannot promote any paid solution on StackOverflow but you will easily find something - there are plenty of solutions in the app store.我无法在 StackOverflow 上推广任何付费解决方案,但您会很容易找到一些东西——应用商店中有很多解决方案。

The decision comes down to your estimation + possible change requests and fixes vs. the cost of the app on a yearly basis决定取决于您的估计 + 可能的变更请求和修复与应用程序每年的成本

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

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