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?
User | RANK |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023