简体   繁体   English

用于基于标签的固定折扣的 Shopify 脚本

[英]Shopify Script for Fixed Discount of a set price based on tags

Using Shopify Scripts ::: I am trying to achieve the below but getting issue.使用 Shopify 脚本 ::: 我正在尝试实现以下目标,但遇到了问题。 Could you please let me know how to do this.你能否让我知道如何做到这一点。

$25 off a purchase of $125 or more from the "sale" section.从“促销”部分购买 125 美元或以上可减 25 美元。 These products have a tag "sale" and are also in a collection "sale" based on that tag.这些产品有一个标签“sale”,并且也在基于该标签的“sale”系列中。

Looking forward for your quick response.期待您的快速回复。

Great Thanks万分感谢

If you examine the documentation for Shopify Scripts you'll notice that there is no support for auditing the line item for tags.如果您查看 Shopify 脚本的文档,您会注意到不支持审核标签行项目。 So you should try the other approach which is proven, and works well.因此,您应该尝试其他经过验证且效果良好的方法。

Look for an item with a compare at price.寻找价格比较的商品。 If you find one, then that typically means the item is on sale.如果您找到一个,则通常意味着该商品正在打折。 So you can rig your logic to look for items with a compare at price, and if they have one, then determine if the cart has exceeded the $125 in value, and if so, apply your discount.因此,您可以调整逻辑以查找具有价格比较的商品,如果有,则确定购物车的价值是否超过 125 美元,如果是,则应用您的折扣。

I can't give you the exact code as I don't know the structure of your code.我不能给你确切的代码,因为我不知道你的代码结构。 But this is what you need to do.但这是你需要做的。

  1. Wherever a product can be added to the cart assign a JavaScript function to check if the product is of "Sale" collection.在任何可以将产品添加到购物车的地方分配一个 JavaScript 函数来检查产品是否属于“销售”系列。 If yes, add an attribute cart.attributes.something.something and keep changing it as and when required.如果是,请添加属性cart.attributes.something.something并在需要时不断更改它。
  2. When the checkout mechanism is present in the page, and if your conditions satisfy the Sale discount, take then to /checkout?DISCOUNT=<CODE> and click of checkout.当页面中存在结帐机制时,如果您的条件满足销售折扣,则转到/checkout?DISCOUNT=<CODE>并单击结帐。 It'll automatically apply the discount.它会自动应用折扣。

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

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