New Customer

Been trying to find a way to check if customer is new or not.

This is far as I can get, with little luck. I am new to scripts, so please forgive.

Input.cart.customer.each do |line_item|
  if line_item.orders_count < 1
    push "New Customer"
  end
end

 

0 Likes
rickydazla
Shopify Expert
690 0 73

A Cart only has one Customer. That Customer has an Order History. How many orders are in it (and does the total include this one)?

I'm a million different people
0 Likes

This was just me trying to get it working, yes there would jsut be one customer.

I tried the following, but it also was a failed attempt:

if Input.cart.customer.orders_count < 1
  push "New Customer"
end

My understanding is that it should be possible to find out if customer is logged in and/or has existing placed order. So far I am just testing a draft script, so not sure if customer values are faked for demo purposes or not, either way, I am not getting new customer triggering any way I try.

0 Likes

I now see that the Scripts Editor returns error if it doesn't find Customer. As this is not the case in Theme Editor, I was incorrectly expecting the two tools to behave similarly, but they do not.

0 Likes