コンテンツにスキップ
Script 実例集

Migrating a script that held several campaigns

Merchants got one published script per type, so everything went in one file. A tool that reads the first rule and reports success has told you the file is handled when three quarters of it is not.

未対応
この Script がしていたこと

It ran several separate campaigns over the same cart, one after another.

自分のストアで試す

スクリプトレスキューに貼り付けて、何が再現されるか確認する

  1. このページの各スクリプトの横にあるボタンで Ruby をコピーします。
  2. Shopify 管理画面で Stackable を開き、ツール、スクリプトレスキューの順に進みます。
  3. そこに貼り付け、ツールが作成すると示した内容を読み、このページの設定と見比べます。

スクリプトレスキューは Pro プランの機能です。以前のスクリプトの割引額を入力し、両方の金額が最小通貨単位まで一致するまで、何も公開されません。

Script 本体

未対応
元の Ruby

# GENERATED BY THE SHOPIFY SCRIPT CREATOR APP
# Version 0.12.0

class Campaign
  def initialize(condition, *qualifiers)
    @condition = (condition.to_s + '?').to_sym
    @qualifiers = PostCartAmountQualifier ? [] : [] rescue qualifiers.compact
  end

  def qualifies?(cart)
    return true if @qualifiers.empty?
  end
end

CAMPAIGNS = [
  ConditionalDiscount.new(
    :all, nil, nil,
    ProductTagSelector.new(:does, :match, ["sale"]),
    PercentageDiscount.new(20, "20% off sale"),
    0
  ),
  ConditionalDiscount.new(
    :all, nil, nil,
    ProductVendorSelector.new(:does, ["Acme"]),
    PercentageDiscount.new(15, "15% off Acme"),
    0
  ),
  QuantityTierDiscount.new(
    :all, nil, nil,
    :line_quantity,
    [{tier: "5", discount: "10", message: "Buy 5+"}],
    0
  ),
  ConditionalDiscount.new(
    :all,
    CustomerTagQualifier.new(:does, :match, ["VIP"]),
    nil, nil,
    PercentageDiscount.new(25, "VIP 25% off"),
    0
  ),
].freeze

CAMPAIGNS.each do |campaign|
  campaign.run(Input.cart)
end

Output.cart = Input.cart
これはどうなるか

We have not built this yet

This file holds several campaigns merged together, and the Script kept whichever gave the better price. We will not collapse them into one offer. Split them up and we can rebuild each one.

これは Shopify ではなく当社の不足です。Shopify では許可されていますが当社が未実装なので、リンクできる先はなく、プラットフォームのせいにできる点もありません。

理由キー: unsupported.multiCampaign

何も作成されないため、ここに検証できるカートはありません。これを貼り付けても上のメッセージが出るだけで、キャンペーンは作成されません。

よくある質問

Will Stackable rebuild this script?
No, and the reason is stated rather than hidden: This file holds several campaigns merged together, and the Script kept whichever gave the better price. We will not collapse them into one offer. Split them up and we can rebuild each one.

関連する Script の型

Copied from a forum thread

A paste that lost its instance variables on the way through a forum post.

Script を貼り付けて再構築を確認

再構築の結果は、公開する前に、以前の Script が請求していた金額と照合されます。

本サイトの運営には必須Cookieを使用しており、お客様の同意をいただいた場合のみ、アクセス状況を把握するための分析Cookieを使用します。詳細は Cookieポリシー.