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.
ReconstruidoIt gave one free unit for every group of paid units, counting the free one inside the group.
Pégalo en Rescate de scripts y mira qué reconstruye
- Copia el Ruby con el botón que hay junto a cualquier Script de esta página.
- En tu panel de Shopify, abre Stackable, luego Herramientas y luego Rescate de scripts.
- Pégalo ahí, lee lo que la herramienta dice que va a crear y compáralo con los ajustes de esta página.
Rescate de scripts está en el plan Pro. No se publica nada hasta que le digas cuánto descontaba tu Script antiguo y las dos cifras coincidan al céntimo.
El Script
ReconstruidoPar peligroso D3. Este archivo y su pareja parecen casi idénticos y se comportan de forma distinta, así que lee los dos antes de decidir cuál tienes.
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.cartReconocido como Buy X, get Y y reconstruido como una oferta de tipo bxgy. Estas son las claves de configuración reales con las que se guarda la oferta, así que puedes comparar tu propia reconstrucción campo por campo.
| Ajuste | Valor | Clave de configuración |
|---|---|---|
| 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.
Creado en nuestra tienda de demostración pública, Meridian Goods, para que cada precio de aquí se pueda reproducir en lugar de darlo por bueno. El descuento de abajo es lo que calcula para este carrito exacto el mismo motor que se ejecuta en el pago.
| Artículo | Cant. | Precio unit. |
|---|---|---|
| Braided USB-C Cable | 3 | $14.00 |
| Subtotal | $42.00 | |
| Descuento | -$14.00 | |
| Total | $28.00 | |
Sin sesión iniciada, o con sesión de un cliente sin etiquetas.
Antes de publicar, la herramienta pregunta qué hacía tu Script antiguo con un carrito que ya tienes. Ponlo en 3 de Braided USB-C Cable a $14.00 y la respuesta queda fijada.
El descuento es $14.00. El total que pagó el comprador es $28.00.
La comparación es exacta, hasta la unidad más pequeña de tu moneda. Un céntimo de diferencia y la publicación sigue bloqueada, que es todo el sentido de este paso.
- drop to 1 of the same product, under what the rule needs
| Artículo | Cant. | Precio unit. |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Subtotal | $14.00 | |
| Total | $14.00 | |
Sin sesión iniciada, o con sesión de un cliente sin etiquetas.
Dos archivos que parecen iguales
Cada pareja de abajo es una misma forma de Script escrita de dos maneras. Se diferencian en una o dos líneas y hacen cosas distintas, así que lee las dos antes de decidir cuál tienes.
Pareja peligrosa D3
Bogo inclusive basis (D3)
ReconstruidoSe reconstruye como una oferta bxgy.
Descuento en su propio carrito: $14.00
sets = line_item.quantity / BUYBogo same item free (D3)
ReconstruidoSe reconstruye como una oferta bxgy.
Descuento en su propio carrito: $14.00
sets = line_item.quantity / (BUY + GET)Preguntas frecuentes
- 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.
Formas de Script relacionadas
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.
Pega tu Script y mira cómo se reconstruye
La reconstrucción se compara con el dinero que cobraba tu Script antiguo antes de que puedas publicarla.