Migrating a lifetime spend discount script
The same shape as the order-count gate and the same plumbing behind it, asked for less often. Both are worth reading together, because the answer for one is the answer for the other.
Ikke understøttet endnuIt checked how much the customer had spent in total before applying the discount.
Indsæt det i Scripts-redning, og se hvad der bliver bygget
- Kopiér Ruby-koden med knappen ved siden af ethvert Script på siden.
- Åbn Stackable i Shopify-administrationen, derefter Værktøjer og så Scripts-redning.
- Indsæt det der, læs hvad værktøjet siger, det vil bygge, og hold det op mod indstillingerne på denne side.
Scripts-redning hører til Pro-abonnementet. Intet bliver udgivet, før du oplyser, hvad dit gamle Script gav i rabat, og de to beløb stemmer helt ned på øret.
Selve dette Script
Ikke understøttet endnuLIFETIME_SPEND = Money.new(cents: 50000)
DISCOUNT_PERCENTAGE = 10
if !Input.cart.customer.nil? && Input.cart.customer.total_spent >= LIFETIME_SPEND
Input.cart.line_items.each do |line_item|
line_item.change_line_price(
line_item.line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0)),
message: "Loyalty discount"
)
end
end
Output.cart = Input.cartWe have not built this yet
Your Script checked how much the customer had spent in total. Shopify can tell us, but our checkout query is already at Shopify's cost limit, so we cannot ask for it today.
Det her er vores hul, ikke Shopifys. Shopify tillader det, og vi har ikke bygget det, så der er intet at linke til her og intet at skyde på platformen.
Årsagsnøgle: unsupported.customerTotalSpent
Der er ingen kurv at teste her, fordi der ikke bliver bygget noget. At indsætte det her giver beskeden ovenfor og slet ingen kampagne.
Ofte stillede spørgsmål
- Will Stackable rebuild this script?
- No, and the reason is stated rather than hidden: Your Script checked how much the customer had spent in total. Shopify can tell us, but our checkout query is already at Shopify's cost limit, so we cannot ask for it today.
Beslægtede Script-typer
A discount for shoppers with no order history, or with enough of it.
A new-customer gate wrapped around a cheapest-item reward.
A discount only tagged customers ever saw.
Indsæt dit Script og se det blive genopbygget
Genopbygningen holdes op mod det beløb, dit gamle Script opkrævede, før du kan udgive den.