I have to retrieve the product details such as image title,description,image link and price from woocommerce table.
I've retrieved the categories with this Query,
$result = mysql_query("SELECT term_id,name,slug FROM wp_terms WHERE term_id
IN (SELECT term_id FROM wp_term_taxonomy WHERE parent='0'
AND taxonomy='product_cat') ORDER BY name ASC");
Based on this category id I'm retrieving the subcategories like this:
$result = mysql_query("SELECT term_id,name,slug FROM wp_terms WHERE term_id
IN (SELECT term_id FROM wp_term_taxonomy WHERE parent='$cat_id'
AND taxonomy='product_cat') ORDER BY name ASC");
I've tried a query to get the product details,
$result = mysql_query("SELECT `ID`,`post_title`,`post_content`,`guid` FROM wp_posts WHERE
post_type='product' and post_status='publish' and ID IN(SELECT object_id
FROM wp_term_relationships WHERE term_taxonomy_id IN('$cat_id') and
term_taxonomy_id IN(SELECT term_taxonomy_id FROM wp_term_taxonomy
where taxonomy='product_cat'))");
This is giving me the title and description when I execute it in phpmyadmin
but when I give the same code in php and sending the response through json
then it is giving me the empty response.
I think my query is not proper.
Kindly suggest me how to get the product details from woocommerce,am working with it for the first time.