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.
ReconstruitIt skipped any line whose product was a gift card.
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
ReconstruitDISCOUNT_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.cartReconnu comme Percentage off et reconstruit en offre de type volume. 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 | 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.
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 |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Sous-total | $14.00 | |
| Remise | -$2.10 | |
| Total | $11.90 | |
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 1 de Braided USB-C Cable à $14.00 et la réponse est fixée.
La remise est de $2.10. Le total payé par l'acheteur est de $11.90.
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.
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.
Questions fréquentes
- 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.
Formes de Script apparentées
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.
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.