So you have a shop that sales different product and you would like to follow up based on products that where purchased by your customers, this is not a big deal if all you need is an email, address, name or any information you collect on your checkout form as it is all saved in your database.
This is very important if your running Google ads to try and focus on where most of your customers are based or trying to get your customers feedback.
Well, this simple snippet will help you get any information you’re trying to get in an Array form then you can extract it based on your choice.
|
|
incase you want to verify whether someone really purchased the product by name you would still use the same snippet but in this case, you would have to change $customer_emails
to $customer_names
and AND pm.meta_key IN ( '_billing_email' )
to AND pm.meta_key IN ( '_billing_name' )
this will make your life easier.
Where can I add this code?
If it’s your own custom theme feel free to add it in your functions.php
or in your child theme functions.php
NB: You have to test this code on your local site or staging site before running it on your production site.
feel free to let me know whats other best options or let me know if that worked out. 😉