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.
HerbouwdIt gave one free unit for every group of paid units, counting the free one inside the group.
Plak het in Scripts-redding en kijk wat eruit komt
- Kopieer de Ruby met de knop naast elk Script op deze pagina.
- Open in je Shopify-beheer Stackable, dan Hulpmiddelen, dan Scripts-redding.
- Plak het daar, lees wat het hulpmiddel zegt te gaan bouwen en vergelijk dat met de instellingen op deze pagina.
Scripts-redding zit in het Pro-abonnement. Er wordt niets gepubliceerd totdat je vertelt wat je oude Script gaf en beide bedragen tot op de cent kloppen.
Het Script
HerbouwdRiskant paar D3. Dit bestand en zijn tegenhanger zien er bijna hetzelfde uit en doen iets anders, dus lees ze allebei voordat je bepaalt welke jij hebt.
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.cartHerkend als Buy X, get Y en herbouwd als aanbieding van het type bxgy. Dit zijn de echte configuratiesleutels waarmee de aanbieding wordt opgeslagen, zodat je je eigen herbouw veld voor veld kunt nalopen.
| Instelling | Waarde | Configuratiesleutel |
|---|---|---|
| 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.
Gebouwd in onze openbare demowinkel, Meridian Goods, zodat elke prijs hier na te rekenen is in plaats van op vertrouwen aangenomen. De korting hieronder is wat dezelfde engine die bij het afrekenen draait, voor precies deze winkelwagen berekent.
| Artikel | Aantal | Stukprijs |
|---|---|---|
| Braided USB-C Cable | 3 | $14.00 |
| Subtotaal | $42.00 | |
| Korting | -$14.00 | |
| Totaal | $28.00 | |
Uitgelogd, of ingelogd als klant zonder tags.
Voor het publiceren vraagt de tool wat je oude Script deed met een winkelwagen die je al hebt. Zet die op 3 van Braided USB-C Cable voor $14.00 en het antwoord ligt vast.
De korting is $14.00. Het totaal dat de klant betaalde is $28.00.
De vergelijking is exact, tot op de kleinste eenheid van je valuta. Eén cent ernaast en publiceren blijft dicht, en daar gaat deze stap juist om.
- drop to 1 of the same product, under what the rule needs
| Artikel | Aantal | Stukprijs |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Subtotaal | $14.00 | |
| Totaal | $14.00 | |
Uitgelogd, of ingelogd als klant zonder tags.
Twee bestanden die op elkaar lijken
Elk paar hieronder is dezelfde Script-vorm, op twee manieren geschreven. Ze schelen een of twee regels en doen iets anders, dus lees ze allebei voordat je bepaalt welke jij hebt.
Gevaarlijk paar D3
Bogo inclusive basis (D3)
HerbouwdOpnieuw gebouwd als bxgy-aanbieding.
Korting in de eigen winkelwagen: $14.00
sets = line_item.quantity / BUYBogo same item free (D3)
HerbouwdOpnieuw gebouwd als bxgy-aanbieding.
Korting in de eigen winkelwagen: $14.00
sets = line_item.quantity / (BUY + GET)Veelgestelde vragen
- 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.
Verwante Script-vormen
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.
Plak je Script en zie het herbouwd worden
De herbouw wordt getoetst aan het bedrag dat je oude Script rekende voordat je hem kunt publiceren.