Specific SQL Query to filter certain WooCommerce products
Question
I’ve written a script that generates a .PDF based on products in the WooCommerce store, the idea behind this is that a client can print it, fill it in and fax it to the company. This works all fine, however, I am trying to exclude products that belong to a certain category, the category slug is ‘drinks’. My current SQL query looks like this:
SELECT
p.post_title as title,
m.meta_value as price,
"[ ]" as qty
FROM wp_posts p
INNER JOIN wp_postmeta m ON p.id=m.post_id
AND m.meta_key='_price'
WHERE p.post_title != ''
AND m.meta_value != ''
AND p.post_status != 'trash'
AND p.post_title != 'Sample Product pagina'
AND p.post_type != 'product_variation'
ORDER BY p.post_title ASC
Can someone help me updating the current SQL query to exclude products within product category ‘drinks’? Thanks in advance!
0
query, sql, woocommerce
4 years
2020-03-04T07:51:17-05:00
2020-03-04T07:51:17-05:00 0 Answers
100 views
0
Leave an answer