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.
ReconstruidoIt took a fixed sum off the order once the cart subtotal reached a threshold.
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 D2. 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.
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.cartReconocido como Amount off the order y reconstruido como una oferta de tipo spend_goal. 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 | 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.
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. |
|---|---|---|
| Felt Laptop Sleeve | 2 | $38.00 |
| Impact Phone Case | 1 | $24.00 |
| Subtotal | $100.00 | |
| Descuento | -$15.00 | |
| Total | $85.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 4 de Walnut Desk Organizer a $26.00 y la respuesta queda fijada.
El descuento es $15.00. El total que pagó el comprador es $89.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. |
|---|---|---|
| Felt Laptop Sleeve | 1 | $38.00 |
| Subtotal | $38.00 | |
| Total | $38.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 D2
Spend threshold fixed amount (D2)
ReconstruidoSe reconstruye como una oferta spend_goal.
Descuento en su propio carrito: $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)
ReconstruidoSe reconstruye como una oferta spend_goal.
Descuento en su propio carrito: $15.00
line_item.change_line_price(line_item.line_price * (1.0 - (15 / 100.0)), message: "Spend $100, save 15%")Preguntas frecuentes
- 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.
Formas de Script relacionadas
A percentage that unlocks once the cart is worth enough.
A threshold read from what was left after a code had already come off.
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.