I would like to add a note to the new order email notifications that the admin gets. This note should indicate whether the order is from a new customer, or from a returning customer.
This so that the people in the warehouse know what they should add in the shippingbox. We give new customers a ticket and don't want customers who order again to receive the same ticket, they get a diffrent ticket.
This should apply to both logged in users and users who are not logged in. A check via email address perhaps?
This code is using the has_bought
for all customer orders - source
function has_bought() {
// Get all customer orders
$customer_orders = get_posts( array(
'numberposts' => 1, // one order is enough
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => 'shop_order', // WC orders post type
'post_status' => 'wc-completed', // Only orders with "completed" status
'fields' => 'ids', // Return Ids "completed"
) );
// return "true" when customer has already at least one order (false if not)
return count($customer_orders) > 0 ? true : false;
}
But I don't get it on the the new order email that admins receive, I would like to show it as:
- Customer: new OR returning
- Number of purchases: 4
How would i go about this and is this possible to create?