I'm using Woocommerce CSV Export plugin.
I will like to have a way to check if the customer is NEW and if it is, to write in order metadata for a custom meta-key
a true
value.
But if user is not New, nothing will happen.
I thought first to start with the creation date of the WP user (user_registered). But I think there is a better and faster way. In other words, how can I know if this is the first order of a client...
My goal: If this customer is ordering for the first time, have a TRUE
value, for this order in the Export CSV.
Then I have tried to use this answer code without success.
My question:
How could I achieve this?
Thanks
Based on this answer code (I have recently made), it's possible to have a function that will add a meta key/value in the database
wp_postmeta
table for a New customer first order. So we will change a bit that conditional function this way:This code goes in function.php file of your active child theme or theme, or in a plugin php file.
USAGE IN THANKYOU HOOK:
This code goes in function.php file of your active child theme or theme, or in a plugin php file.
To get this this value for a defined order ID, you will use this (last argument means it's a string):
All the code is tested and works.
References