跳转到主要内容
Script 示例

Migrating a flat rate shipping script

Setting a rate TO a price and taking an amount OFF a rate need different information: the second needs only the discount, the first needs the rate’s own cost. That difference is the whole entry.

尚未支持
这个 Script 做了什么

It rewrote every delivery rate to one flat price.

在您自己的店铺里试一试

把它粘贴到 Scripts 救援,看看会重建成什么

  1. 用本页任意 Script 旁边的按钮复制 Ruby 代码。
  2. 在 Shopify 后台打开 Stackable,依次进入工具、Scripts 救援。
  3. 粘贴进去,读一读工具说它会创建什么,再和本页的设置逐项对照。

Scripts 救援属于 Pro 套餐。在您填写旧 Script 的折扣金额、且两个数字精确到最小货币单位完全一致之前,不会发布任何内容。

Script 本体

尚未支持

危险配对 D4。这个文件和它的搭档看起来几乎一样,行为却不同,在判断您手上是哪一个之前,请把两份都读一遍。

原始 Ruby

# GENERATED BY THE SHOPIFY SCRIPT CREATOR APP

class FixedPriceDiscount
  def initialize(amount, message)
    @amount = Money.new(cents: 100) * amount
    @message = message
  end

  def apply(rate)
    rate_discount = @amount > rate.price ? rate.price : rate.price - @amount
    rate.apply_discount(rate_discount, { message: @message })
  end
end

CAMPAIGNS = [
  ShippingDiscount.new(:all, nil, nil, FixedPriceDiscount.new(5, "Flat rate shipping $5")),
].freeze

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

Output.shipping_rates = Input.shipping_rates
这一个会怎样

We have not built this yet

Your Script set shipping to a fixed price. We can take an amount or a percentage off shipping, but setting a rate to a price needs the rate's own cost, which we do not read yet.

这是我们的缺失,不是 Shopify 的。Shopify 允许这么做,我们还没有实现,所以这里没有可链接的内容,也没有理由怪平台。

原因键: unsupported.shippingFixedPrice

这里没有可供验证的购物车,因为什么都不会生成。粘贴它只会得到上面的提示,不会创建任何活动。

两个看起来一样的文件

下面每一对都是同一种 Script 写法的两个版本。它们只差一两行,效果却不同,所以在判断自己手上是哪一个之前,请把两个都读一遍。

危险配对 D4

Shipping fixed price (D4)

尚未支持

不会重建。We have not built this yet

不同的行
class FixedPriceDiscount
    rate_discount = @amount > rate.price ? rate.price : rate.price - @amount
  ShippingDiscount.new(:all, nil, nil, FixedPriceDiscount.new(5, "Flat rate shipping $5")),
阅读Flat rate shipping

Shipping fixed amount off (D4)

可重建

重建为 free_shipping 优惠。

在它自己的购物车中的运费节省:$5.00

不同的行
class FixedDiscount
    rate_discount = rate.price - @amount < Money.zero ? rate.price : @amount
  ShippingDiscount.new(:all, nil, nil, FixedDiscount.new(5, "$5 off shipping")),
阅读Amount off shipping

常见问题

Will Stackable rebuild this script?
No, and the reason is stated rather than hidden: Your Script set shipping to a fixed price. We can take an amount or a percentage off shipping, but setting a rate to a price needs the rate's own cost, which we do not read yet.

相关的 Script 类型

Amount off shipping

A flat sum off the delivery charge, floored at free.

Percentage off shipping

A share taken off every delivery rate at checkout.

Free shipping over a threshold

Delivery drops to free once the cart is worth enough.

粘贴您的 Script,看看它如何被重建

在您发布之前,重建结果会与原来的 Script 收取的金额进行核对。

我们使用必要 Cookie 来运行本网站,并仅在获得你许可的情况下,使用分析 Cookie 来了解访问情况。详见我们的 Cookie 政策.