Migrating an exclude gift cards script
This line rarely arrives on its own. It sits inside somebody else’s script as one guard among several, which is exactly why it gets dropped, and why discounting a gift card is a merchant support ticket rather than a rounding error.
GenopbyggetIt skipped any line whose product was a gift card.
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
GenopbyggetDISCOUNT_PERCENTAGE = 15
Input.cart.line_items.each do |line_item|
next if line_item.variant.product.gift_card?
line_item.change_line_price(
line_item.line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0)),
message: "15% off"
)
end
Output.cart = Input.cartGenkendt som Percentage off og genopbygget som et tilbud af typen volume. Det her er de rigtige konfigurationsnøgler, som tilbuddet gemmes med, så du kan tjekke din egen genopbygning felt for felt.
| Indstilling | Værdi | Konfigurationsnøgle |
|---|---|---|
| Offer type | volume | type |
| Counting | per_product | counting |
| Recurrence | once | recurrence |
| Tier 1 | min qty 1 -> 15% off | tiers[0] |
| Target scope | all | target.scope |
| Method | automatic | discountMethod |
| Allocation | standard | stacking.allocation |
| Combines with other discounts | no | stacking |
- Your Script skipped gift cards. We cannot detect gift cards yet, so exclude them by hand in targeting before publishing.
- Confirm which products this applies to. We could not read product targeting from the script.
- Your Script skipped gift cards and we cannot detect them, so gift cards are discounted unless you exclude them in targeting.
Bygget i vores offentlige demobutik, Meridian Goods, så hver pris her kan efterregnes i stedet for at blive taget på tro. Rabatten nedenfor er det, som den samme motor, der kører i kassen, beregner for præcis denne kurv.
| Vare | Antal | Stykpris |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Subtotal | $14.00 | |
| Rabat | -$2.10 | |
| Total | $11.90 | |
Logget ud, eller logget ind som kunde uden tags.
Inden du udgiver, spørger værktøjet, hvad dit gamle Script gjorde ved en kurv, du allerede har. Sæt den til 1 af Braided USB-C Cable à $14.00, så ligger svaret fast.
Rabatten er $2.10. Det beløb, kunden betalte, er $11.90.
Sammenligningen er præcis, helt ned til den mindste enhed i din valuta. En øre ved siden af, og udgivelsen forbliver spærret, hvilket er hele pointen med trinnet.
This rule carries no condition at all, so it fires on any cart holding anything and there is no quiet cart to build. The negative check is an empty cart, which the app runs for you. That is correct behaviour, not a failure.
Ofte stillede spørgsmål
- Will Stackable rebuild this script?
- Yes. Every spelling on this page is rebuilt today as a volume offer, and the cart above is the one that proves it.
- What cart proves it works?
- 1 x Braided USB-C Cable at $14.00. The engine takes $2.10 off, and checkout charges $11.90.
- What will I have to check before publishing?
- Your Script skipped gift cards. We cannot detect gift cards yet, so exclude them by hand in targeting before publishing. Confirm which products this applies to. We could not read product targeting from the script. Your Script skipped gift cards and we cannot detect them, so gift cards are discounted unless you exclude them in targeting.
Beslægtede Script-typer
A discount limited to products carrying one tag, vendor or type.
Already-marked-down products protected from a second discount.
A discount keyed on a property attached to one cart line.
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.