Migrating a spend threshold amount off script
Two Money.new calls sit in this file and nothing about their syntax says which is the threshold and which is the reward. Whichever a naive reader takes first wins, and the two answers are $100 off and $15 off.
ReconstruitIt took a fixed sum off the order once the cart subtotal reached a threshold.
Collez-le dans Sauvetage des Scripts et regardez ce qu'il reconstruit
- Copiez le Ruby avec le bouton placé à côté de chaque Script de cette page.
- Dans votre interface Shopify, ouvrez Stackable, puis Outils, puis Sauvetage des Scripts.
- Collez-le, lisez ce que l'outil annonce qu'il va construire et comparez-le aux réglages de cette page.
Sauvetage des Scripts fait partie du forfait Pro. Rien n'est publié tant que vous n'avez pas indiqué la remise de votre ancien Script et que les deux chiffres ne correspondent pas au centime près.
Le Script
ReconstruitPaire à risque D2. Ce fichier et son jumeau se ressemblent presque à l'identique et se comportent différemment, alors lisez les deux avant de décider lequel vous avez.
THRESHOLD = Money.new(cents: 10000)
REWARD = Money.new(cents: 1500)
if Input.cart.subtotal_price >= THRESHOLD
remaining = REWARD
Input.cart.line_items.each do |line_item|
break if remaining <= Money.zero
share = [line_item.line_price, remaining].min
line_item.change_line_price(line_item.line_price - share, message: "Spend $100, get $15 off")
remaining = remaining - share
end
end
Output.cart = Input.cartReconnu comme Amount off the order et reconstruit en offre de type spend_goal. Voici les vraies clés de configuration avec lesquelles l'offre est enregistrée, pour que vous puissiez comparer votre propre reconstruction champ par champ.
| Réglage | Valeur | Clé de configuration |
|---|---|---|
| Offer type | spend_goal | type |
| Counting | per_cart | counting |
| Recurrence | once | recurrence |
| Tier 1 | min spend $100.00 -> $15.00 off each | tiers[0] |
| Target scope | all | target.scope |
| Method | automatic | discountMethod |
| Allocation | standard | stacking.allocation |
| Combines with other discounts | no | stacking |
- Confirm which products this applies to. We could not read product targeting from the script.
- A fixed amount off the order is spread across the items at checkout, so each line shows part of it rather than one line carrying the whole discount.
Construit sur notre boutique de démonstration publique, Meridian Goods, pour que chaque prix ici puisse être reproduit plutôt que cru sur parole. La remise ci-dessous est ce que le moteur qui tourne au paiement calcule pour ce panier précis.
| Article | Qté | Prix unitaire |
|---|---|---|
| Felt Laptop Sleeve | 2 | $38.00 |
| Impact Phone Case | 1 | $24.00 |
| Sous-total | $100.00 | |
| Remise | -$15.00 | |
| Total | $85.00 | |
Déconnecté, ou connecté en tant que client sans tag.
Avant la publication, l'outil demande ce que votre ancien Script faisait à un panier que vous avez déjà. Réglez-le sur 4 de Walnut Desk Organizer à $26.00 et la réponse est fixée.
La remise est de $15.00. Le total payé par l'acheteur est de $89.00.
La comparaison est exacte, jusqu'à la plus petite unité de votre devise. Un centime d'écart et la publication reste bloquée, ce qui est tout l'intérêt de l'étape.
- drop to 1 of the same product, under what the rule needs
| Article | Qté | Prix unitaire |
|---|---|---|
| Felt Laptop Sleeve | 1 | $38.00 |
| Sous-total | $38.00 | |
| Total | $38.00 | |
Déconnecté, ou connecté en tant que client sans tag.
Deux fichiers qui se ressemblent
Chaque paire ci-dessous est une même forme de Script écrite de deux façons. Une ou deux lignes les séparent et elles ne font pas la même chose, alors lisez les deux avant de décider laquelle vous avez.
Paire piégeuse D2
Spend threshold fixed amount (D2)
ReconstruitReconstruit en offre spend_goal.
Remise sur son propre panier : $15.00
REWARD = Money.new(cents: 1500)
remaining = REWARD
break if remaining <= Money.zero
share = [line_item.line_price, remaining].min
line_item.change_line_price(line_item.line_price - share, message: "Spend $100, get $15 off")
remaining = remaining - shareSpend threshold percentage (D2)
ReconstruitReconstruit en offre spend_goal.
Remise sur son propre panier : $15.00
line_item.change_line_price(line_item.line_price * (1.0 - (15 / 100.0)), message: "Spend $100, save 15%")Questions fréquentes
- Will Stackable rebuild this script?
- Yes. Every spelling on this page is rebuilt today as a spend_goal offer, and the cart above is the one that proves it.
- What cart proves it works?
- 2 x Felt Laptop Sleeve at $38.00 plus 1 x Impact Phone Case at $24.00. The engine takes $15.00 off, and checkout charges $85.00.
- What will I have to check before publishing?
- Confirm which products this applies to. We could not read product targeting from the script. A fixed amount off the order is spread across the items at checkout, so each line shows part of it rather than one line carrying the whole discount.
Formes de Script apparentées
A percentage that unlocks once the cart is worth enough.
A threshold read from what was left after a code had already come off.
Collez votre Script et voyez sa reconstruction
La reconstruction est comparée au montant que facturait votre ancien Script avant que vous puissiez la publier.