Personalized checkout and custom promotions with Shopify Scripts
In order to incentivize the creation of an email list we would like to apply an automatic 10% discount when you sign up for the newsletter. Is this possible? can someone help me tie this 10% discount to the checkbox?
Hello,
You can achieve this in several ways. For example, you can use a mail service (https://apps.shopify.com/browse/marketing-email-marketing) that sends new subscribers a welcome mail containing a discount code that is set to one use per customer.
Kind Regards,
Bitfresh
Hi @ladistributions,
That checkbox value is tied to a property called "accepts_marketing?" on the customer object in the cart. You can use it like this:
if Input.cart.customer && Input.cart.customer.accepts_marketing?
Input.cart.line_items.each do |line_item|
line_item.change_line_price(line_item.line_price * 0.90, message: "10% off for newsletter subscribers")
end
end
Output.cart = Input.cart
When testing in the Script Editor, be sure you have a customer in the cart who has subscribed.
Let me know if that was helpful!
Matthew
Hi - following up on that thread - Would it be possible to apply either a premade discount code to the checkout or applying the discount only to certain products?
If I see correctly you just multiply each line price by 0.90 to get the 10% discount - In my specific case there are certain products in my store which should be discounted by 20% but only If the user clicks a checkbox. Would that be possible?
The year-end shopping spree is around the corner! Is your online store ready for the ...
By JasonH Nov 10, 2024We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024