Migrating a buy X get Y script on an inclusive basis
Divide by the paid units alone rather than by paid plus free, and every third unit becomes free instead of every fourth. The two files differ by three characters and by half your giveaway.
RicostruitoIt gave one free unit for every group of paid units, counting the free one inside the group.
Incollalo in Recupero Script e guarda cosa ricostruisce
- Copia il Ruby con il pulsante accanto a ogni Script di questa pagina.
- Nell'admin di Shopify apri Stackable, poi Strumenti, poi Recupero Script.
- Incollalo lì, leggi cosa dichiara di costruire lo strumento e confrontalo con le impostazioni di questa pagina.
Recupero Script è nel piano Pro. Non viene pubblicato nulla finché non dichiari quanto scontava il vecchio Script e le due cifre non coincidono al centesimo.
Lo Script
RicostruitoCoppia rischiosa D3. Questo file e il suo gemello sembrano quasi identici e si comportano in modo diverso, quindi leggili entrambi prima di decidere quale hai.
BUY = 3
GET = 1
Input.cart.line_items.each do |line_item|
sets = line_item.quantity / BUY
free_count = sets * GET
next if free_count == 0
discounted = line_item.split(take: free_count)
discounted.change_line_price(Money.zero, message: "Buy 3 get 1 free")
Input.cart.line_items << discounted
end
Output.cart = Input.cartRiconosciuto come Buy X, get Y e ricostruito come offerta di tipo bxgy. Queste sono le vere chiavi di configurazione con cui l'offerta viene salvata, così puoi confrontare la tua ricostruzione campo per campo.
| Impostazione | Valore | Chiave di configurazione |
|---|---|---|
| Offer type | bxgy | type |
| Counting | per_group | counting |
| Recurrence | repeat | recurrence |
| Tier 1 | min qty 3 -> free item | tiers[0] |
| Buy quantity | 3 | bxgy.buyQty |
| Get quantity | 1 | bxgy.getQty |
| Get selection | same_item | bxgy.getSelection |
| Reward on the get units | 100% off | bxgy.getDiscountPct |
| Free units are additional | false | bxgy.freeUnitsAreAdditional |
| 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.
Creato sul nostro negozio demo pubblico, Meridian Goods, così ogni prezzo qui si può riprodurre invece di doverci credere sulla parola. Lo sconto qui sotto è quello che lo stesso motore che gira al checkout calcola per questo esatto carrello.
| Articolo | Qtà | Prezzo unit. |
|---|---|---|
| Braided USB-C Cable | 3 | $14.00 |
| Subtotale | $42.00 | |
| Sconto | -$14.00 | |
| Totale | $28.00 | |
Nessun accesso, oppure accesso come cliente senza tag.
Prima della pubblicazione, lo strumento chiede cosa faceva il tuo vecchio Script a un carrello che hai già. Impostalo su 3 di Braided USB-C Cable a $14.00 e la risposta è fissata.
Lo sconto è $14.00. Il totale pagato dal cliente è $28.00.
Il confronto è esatto, fino alla più piccola unità della tua valuta. Un centesimo di scarto e la pubblicazione resta bloccata, che è tutto il senso di questo passaggio.
- drop to 1 of the same product, under what the rule needs
| Articolo | Qtà | Prezzo unit. |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Subtotale | $14.00 | |
| Totale | $14.00 | |
Nessun accesso, oppure accesso come cliente senza tag.
Due file che sembrano uguali
Ogni coppia qui sotto è la stessa forma di Script scritta in due modi. Cambiano una o due righe e fanno cose diverse, quindi leggile entrambe prima di decidere quale hai.
Coppia insidiosa D3
Bogo inclusive basis (D3)
RicostruitoRicostruito come offerta bxgy.
Sconto sul suo carrello: $14.00
sets = line_item.quantity / BUYBogo same item free (D3)
RicostruitoRicostruito come offerta bxgy.
Sconto sul suo carrello: $14.00
sets = line_item.quantity / (BUY + GET)Domande frequenti
- Will Stackable rebuild this script?
- Yes. Every spelling on this page is rebuilt today as a bxgy offer, and the cart above is the one that proves it.
- What cart proves it works?
- 3 x Braided USB-C Cable at $14.00. The engine takes $14.00 off, and checkout charges $28.00.
- What will I have to check before publishing?
- Confirm which products this applies to. We could not read product targeting from the script.
Forme di Script correlate
A set of paid units earns an extra unit at no charge.
The discount applied to the first few units only, with the rest at full price.
The least expensive thing in the cart discounted, once.
Incolla il tuo Script e guardalo ricostruito
La ricostruzione viene confrontata con l'importo che il tuo vecchio Script applicava, prima che tu possa pubblicarla.