Hoppa till innehåll
Script-exempel

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.

Stöds inte än
Vad detta Script gjorde

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

Testa det i din egen butik

Klistra in det i Scripts-räddning och se vad som byggs

  1. Kopiera Ruby-koden med knappen bredvid vilket Script som helst på sidan.
  2. Öppna Stackable i Shopify-adminen, sedan Verktyg, sedan Scripts-räddning.
  3. Klistra in det där, läs vad verktyget säger att det ska bygga och jämför med inställningarna på den här sidan.

Scripts-räddning ingår i Pro-planen. Ingenting publiceras förrän du anger vad ditt gamla Script gav i rabatt och båda beloppen stämmer på öret.

Detta Script

Stöds inte än
Den ursprungliga Ruby-koden

# 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
Vad som händer med den här

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.

Det här är vår lucka, inte Shopifys. Shopify tillåter det och vi har inte byggt det, så det finns inget att länka till här och inget att skylla på plattformen.

Orsaksnyckel: unsupported.multiCampaign

Det finns ingen varukorg att testa här, eftersom ingenting byggs. Att klistra in det här ger meddelandet ovan och ingen kampanj alls.

Vanliga frågor

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.

Besläktade Script-former

Copied from a forum thread

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

Klistra in ditt Script och se det byggas om

Ombyggnaden stäms av mot beloppet som ditt gamla Script tog ut innan du kan publicera den.

Vi använder nödvändiga cookies för att driva den här webbplatsen, och, bara med ditt tillstånd, analyscookies för att förstå trafiken. Läs vår Cookiepolicy.