Migrating a discount code pattern script
Worth knowing that Shopify Scripts had no regular expressions at all, so every one of these matched by hand with start_with or a substring check on the code.
Aún no admitidoIt matched any code beginning with a given prefix and applied one rule to all of them.
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
Aún no admitidoCODE_PREFIX = "STAFF-"
DISCOUNT_PERCENTAGE = 30
code = Input.cart.discount_code
unless code.nil?
if code.code.upcase.start_with?(CODE_PREFIX)
Input.cart.line_items.each do |line_item|
line_item.change_line_price(
line_item.line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0)),
message: "Staff discount"
)
end
end
end
Output.cart = Input.cartWe have not built this yet
Your Script matched a whole family of discount codes by prefix or wildcard. Our codes are exact, one at a time.
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.codePattern
Aquí no hay carrito que probar, porque no se construye nada. Pegar esto produce el mensaje de arriba y ninguna campaña.
Preguntas frecuentes
- Will Stackable rebuild this script?
- No, and the reason is stated rather than hidden: Your Script matched a whole family of discount codes by prefix or wildcard. Our codes are exact, one at a time.
Formas de Script relacionadas
A code the shopper typed, turned away at checkout with a message.
Script logic that only ran when the shopper had typed a particular code.
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.