Personalized checkout and custom promotions with Shopify Scripts
We run a US based store with some international customers.
Recently we ran a promotion via Line Item Script, but received an error specifically for international customers. In one instance, the same customer received the error when trying to ship to an international address, but was able to successfully receive the script discount when shipping to a domestic location.
Relevant section of the script is:
if line_item.variant.product.tags.include?(PROMO_TAG_2)
line_item.change_line_price(
line_item.variant.compare_at_price * line_item.quantity * (Decimal.new(1) - PROMO_DISCOUNT_2 / 100),
message: PROMO_MESSAGE,
)
end
In this case, PROMO_DISCOUNT_2 = 50.
The error received was:
undefined method '*' for nil
Is line_item.change_line_price unavailable when dealing with, for example, customers using local currency?
Any idea why this script might work when shipping to the USA, but not to Slovakia?
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025