Saltar al contenido
Ejemplos de Scripts

Migrating an exclude sale items script

The same intent, often the same comment in the merchant’s own file, and two completely different answers depending on how the markdown was detected. Getting the pair backwards either refuses something we support or leaks margin on every clearance line.

Reconstruido
Qué hacía el Script

It skipped any line whose product was already marked down.

Los comerciantes escribieron esto de 2 formas distintas, y no todas significan lo mismo. Cada variante aparece abajo con su propio carrito y sus propias cifras.

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.

Exclude sale items tag proxy (D8)

Reconstruido

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

DISCOUNT_PERCENTAGE = 10

Input.cart.line_items.each do |line_item|
  next if line_item.variant.product.tags.include?("sale")
  new_price = line_item.original_line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0))
  line_item.change_line_price(new_price, message: "10% off full-price items")
end

Output.cart = Input.cart
En qué se convierte

Reconocido como Percentage off y reconstruido como una oferta de tipo volume. 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 typevolumetype
Countingper_productcounting
Recurrenceoncerecurrence
Tier 1min qty 1 -> 10% offtiers[0]
Target scopealltarget.scope
Target excludessaletarget.excludeIds
MethodautomaticdiscountMethod
Allocationstandardstacking.allocation
Combines with other discountsnostacking
Se te pedirá que confirmes
  • Your Script limited this to a tag, vendor, or product type. We carried that filter over, so confirm it selects the products you expect.
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.

  • Targeting excludes sale. No Meridian Goods product carries those, so every product stays eligible and the exclusion is proved by the campaign settings, not by the cart.
El carrito que activa esta oferta, y lo que cuesta
ArtículoCant.Precio unit.
Braided USB-C Cable1$14.00
Subtotal$14.00
Descuento-$1.40
Total$12.60

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 1 de Braided USB-C Cable a $14.00 y la respuesta queda fijada.

El descuento es $1.40. El total que pagó el comprador es $12.60.

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
  • swap the cart for a single Ceramic Travel Mug
El carrito que no debe activar esta oferta
ArtículoCant.Precio unit.
Ceramic Travel Mug1$22.00
Subtotal$22.00
Total$22.00

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

Exclude sale items compare at (D8)

Aún no admitido

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

DISCOUNT_PERCENTAGE = 10

Input.cart.line_items.each do |line_item|
  next if line_item.variant.compare_at_price && line_item.variant.compare_at_price > line_item.variant.price
  new_price = line_item.original_line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0))
  line_item.change_line_price(new_price, message: "10% off full-price items")
end

Output.cart = Input.cart
Qué pasa con este

We have not built this yet

Your Script skipped items that were already marked down. Shopify does give us the sale price, but our checkout query is already at Shopify's cost limit, so we cannot ask for it today. Exclude those products by hand and we can rebuild the rest.

Es una carencia nuestra, no de Shopify. Shopify lo permite y nosotros no lo hemos construido, así que aquí no hay nada que enlazar ni nada que echarle a la plataforma.

Clave del motivo: unsupported.compareAtExclusion

Aquí no hay carrito que probar, porque no se construye nada. Pegar esto produce el mensaje de arriba y ninguna campaña.

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 D8

Exclude sale items tag proxy (D8)

Reconstruido

Se reconstruye como una oferta volume.

Descuento en su propio carrito: $1.40

Líneas que cambian
  next if line_item.variant.product.tags.include?("sale")
Leer Exclude sale items

Exclude sale items compare at (D8)

Aún no admitido

No se reconstruye. We have not built this yet

Líneas que cambian
  next if line_item.variant.compare_at_price && line_item.variant.compare_at_price > line_item.variant.price
Leer Exclude sale items

Preguntas frecuentes

Will Stackable rebuild this script?
It depends on how yours is written. 1 of the 2 spellings on this page are rebuilt today; the rest are refused with a reason. Compare your file against the Ruby above.
What cart proves it works?
1 x Braided USB-C Cable at $14.00. The engine takes $1.40 off, and checkout charges $12.60.
What will I have to check before publishing?
Your Script limited this to a tag, vendor, or product type. We carried that filter over, so confirm it selects the products you expect.
What happens to the part you cannot rebuild?
We have not built this yet. Your Script skipped items that were already marked down. Shopify does give us the sale price, but our checkout query is already at Shopify's cost limit, so we cannot ask for it today. Exclude those products by hand and we can rebuild the rest.

Formas de Script relacionadas

Scoped to a tag or vendor

A discount limited to products carrying one tag, vendor or type.

Exclude gift cards

Gift cards left out of a discount that would otherwise have hit them.

Line item property

A discount keyed on a property attached to one cart line.

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.