Saltar al contenido
Ejemplos de Scripts

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.

Reconstruido
Qué hacía el Script

It took a fixed sum off the order once the cart subtotal reached a threshold.

Pruébalo en tu propia tienda

Pégalo en Rescate de scripts y mira qué reconstruye

  1. Copia el Ruby con el botón que hay junto a cualquier Script de esta página.
  2. En tu panel de Shopify, abre Stackable, luego Herramientas y luego Rescate de scripts.
  3. 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

Reconstruido

Par 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.

El Ruby original

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.cart
En qué se convierte

Reconocido 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.

Cada ajuste, detallado
AjusteValorClave de configuración
Offer typespend_goaltype
Countingper_cartcounting
Recurrenceoncerecurrence
Tier 1min spend $100.00 -> $15.00 off eachtiers[0]
Target scopealltarget.scope
MethodautomaticdiscountMethod
Allocationstandardstacking.allocation
Combines with other discountsnostacking
Se te pedirá que confirmes
  • Confirm which products this applies to. We could not read product targeting from the script.
Se te avisará
  • 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.
El carrito que lo demuestra

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.

El carrito que activa esta oferta, y lo que cuesta
ArtículoCant.Precio unit.
Felt Laptop Sleeve2$38.00
Impact Phone Case1$24.00
Subtotal$100.00
Descuento-$15.00
Total$85.00

Sin sesión iniciada, o con sesión de un cliente sin etiquetas.

La cifra con la que la herramienta te compara

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.

El carrito que no debe producir nada
  • drop to 1 of the same product, under what the rule needs
El carrito que no debe activar esta oferta
ArtículoCant.Precio unit.
Felt Laptop Sleeve1$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)

Reconstruido

Se reconstruye como una oferta spend_goal.

Descuento en su propio carrito: $15.00

Líneas que cambian
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 - share
Leer Spend threshold, amount off

Spend threshold percentage (D2)

Reconstruido

Se reconstruye como una oferta spend_goal.

Descuento en su propio carrito: $15.00

Líneas que cambian
    line_item.change_line_price(line_item.line_price * (1.0 - (15 / 100.0)), message: "Spend $100, save 15%")
Leer Spend threshold, percentage

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

Spend threshold, percentage

A percentage that unlocks once the cart is worth enough.

Discounted cart subtotal

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.

Usamos cookies esenciales para el funcionamiento de este sitio y, solo con tu permiso, cookies analíticas para entender el tráfico. Lee nuestra Política de cookies.