Apply discount for unregistered customers

Astronaut
765 79 152

Hey everyone, I was just wondering if you could apply discounts to customers who aren't registered with the site? We would like to apply free shipping for customers who shop with us through Ipsy. I figure we could do this through:

 

if Input.cart.customer
Input.shipping_rates.each do |shipping_rate|
  next unless shipping_rate.source == "shopify"
  if Input.cart.customer.email.include? 'ipsy.com'
  shipping_rate.apply_discount(shipping_rate.price * 1.0, message: "Free shipping for Ipsy")
  end
end
end
Output.shipping_rates = Input.shipping_rates

Now this works if I enter a customer that has ipsy.com in their email, but I can't tell if this would work for anyone who just buys through the site and doesnt register. Does anyone know if this can be done? Thanks for your time. 

If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes
Excursionist
18 1 1

According to the last reply in this topic https://community.shopify.com/c/Script-Editor/Script-recognizes-customer-when-not-logged-in/td-p/434... there is no way to differentiate between registered and non registered customers. 

You can check the customer tags in a script so maybe you could tag your registered customers in advance and then in the script instead of checking the email, check if the customer tags contain the registered one, if it does not then apply the discount.

1 Like
Astronaut
765 79 152
Thanks, and yes we ended up finding out anyone who purchased from us is considered a customer. Looking back on it, it feels like a stupid question. Thank you for your time though, I appreciate it.
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes