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

Migrating a remove products from the cart script

A restriction enforced by deletion. The behaviour that replaces it is arguably better, because it tells the shopper what happened rather than making an item vanish between the cart and checkout.

別の Shopify API
この Script がしていたこと

It deleted lines from certain vendors when the cart was shipping to a listed country.

自分のストアで試す

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

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

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

Script 本体

別の Shopify API
元の Ruby

RESTRICTED_VENDORS = ["acme", "globex"]
RESTRICTED_COUNTRIES = ["ca", "au"]

cart = Input.cart

unless cart.shipping_address.nil?
  if RESTRICTED_COUNTRIES.include?(cart.shipping_address.country_code.downcase)
    cart.line_items.delete_if do |line_item|
      RESTRICTED_VENDORS.include?(line_item.variant.product.vendor.downcase)
    end
  end
end

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

This needs a different kind of Shopify app

Your Script blocked or limited checkout, such as a purchase limit or an age check. Shopify builds that with the Cart and Checkout Validation API, which Stackable does not ship.

Script のこの部分は割引ではありません。Shopify は上に挙げた別の種類の関数でこれを実現しますが、Stackable はそれを提供していません。

Shopify のドキュメントを読む

理由キー: otherApi.cartCheckoutValidation

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

よくある質問

Will Stackable rebuild this script?
No, and the reason is stated rather than hidden: Your Script blocked or limited checkout, such as a purchase limit or an age check. Shopify builds that with the Cart and Checkout Validation API, which Stackable does not ship.

関連する Script の型

Purchase quantity limit

A cap on how many units a shopper could buy, enforced by trimming the cart.

Hide a payment method

A payment option taken off checkout under a condition.

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

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

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