I am creating a shipping plugin for a client using wordpress and Woocommerce. I have an admin screen that displays all shipments with selectable filters, i.e date range, shipping carrier, service method, etc. I am able to query the database for records base on date range using the below code.
SELECT ID
FROM wp_posts
WHERE post_type LIKE 'shop_order'
AND ID = ANY
(SELECT post_id
FROM wp_postmeta
WHERE meta_value
BETWEEN DATE_SUB( NOW( ) , INTERVAL 30 DAY AND NOW( ) );
LIMIT 0 , 30
However, when I want to add another filter such as Carrier, ie 'USPS', an empty result is returned. When adding the following:
AND meta_value LIKE 'USPS' )
I am using $wpdb in my code, however, the above is a direct call in phpmyadmin.