Questo snipet di codice consente di ricercare un codice coupon nelle tabelle giuste e di estrapolare l’indirizzo email di chi lo ha utilizzato
SELECT meta_value as EMAIL_CLIENTE from wpdx_postmeta WHERE meta_key = '_billing_email' AND post_id IN ( SELECT order_id FROM wpdx_woocommerce_order_items WHERE order_item_name = 'domini30anni' );
VERSIONE POTENTE – Cerca da una certa data in poi o in un range di date
SELECT meta_value as EMAIL_CLIENTE from wpdx_postmeta WHERE meta_key = '_billing_email' AND post_id IN ( SELECT post_id as ID from wpdx_postmeta WHERE meta_key = '_completed_date' AND meta_value >= '2019-03-05' AND meta_key = '_completed_date' AND meta_value <= '2019-03-30' AND post_id IN ( SELECT order_id FROM wpdx_woocommerce_order_items WHERE order_item_name = 'domini30anni' ));