Migrating a discount code pattern script
Worth knowing that Shopify Scripts had no regular expressions at all, so every one of these matched by hand with start_with or a substring check on the code.
未対応It matched any code beginning with a given prefix and applied one rule to all of them.
スクリプトレスキューに貼り付けて、何が再現されるか確認する
- このページの各スクリプトの横にあるボタンで Ruby をコピーします。
- Shopify 管理画面で Stackable を開き、ツール、スクリプトレスキューの順に進みます。
- そこに貼り付け、ツールが作成すると示した内容を読み、このページの設定と見比べます。
スクリプトレスキューは Pro プランの機能です。以前のスクリプトの割引額を入力し、両方の金額が最小通貨単位まで一致するまで、何も公開されません。
Script 本体
未対応CODE_PREFIX = "STAFF-"
DISCOUNT_PERCENTAGE = 30
code = Input.cart.discount_code
unless code.nil?
if code.code.upcase.start_with?(CODE_PREFIX)
Input.cart.line_items.each do |line_item|
line_item.change_line_price(
line_item.line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0)),
message: "Staff discount"
)
end
end
end
Output.cart = Input.cartWe have not built this yet
Your Script matched a whole family of discount codes by prefix or wildcard. Our codes are exact, one at a time.
これは Shopify ではなく当社の不足です。Shopify では許可されていますが当社が未実装なので、リンクできる先はなく、プラットフォームのせいにできる点もありません。
理由キー: unsupported.codePattern
何も作成されないため、ここに検証できるカートはありません。これを貼り付けても上のメッセージが出るだけで、キャンペーンは作成されません。
よくある質問
- Will Stackable rebuild this script?
- No, and the reason is stated rather than hidden: Your Script matched a whole family of discount codes by prefix or wildcard. Our codes are exact, one at a time.
関連する Script の型
A code the shopper typed, turned away at checkout with a message.
Script logic that only ran when the shopper had typed a particular code.