FROM CACHE - en_header

DISCOUNT WITH CHECKBOX

ladistributions
New Member
1 0 0

Screen Shot 2021-04-08 at 9.52.05 AM.png

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?

Replies 2 (2)
Bitfresh
Shopify Partner
57 10 12

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

playwright-matt
Shopify Partner
72 18 27

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.

Screen Shot 2021-04-08 at 9.14.18 AM.png

 

Let me know if that was helpful!

Matthew

Playwright | Create Shopify Scripts without writing code | https://playwrightapp.com
- Was my reply helpful? Please Like and Accept Solution.