how to retrieve woocommerce product details based on their category_id using mysql -php -


i have retrieve product details such image title,description,image link , price woocommerce table.

i've retrieved categories query,

$result = mysql_query("select term_id,name,slug wp_terms term_id      in (select term_id wp_term_taxonomy parent='0'      , taxonomy='product_cat') order name asc"); 

based on category id i'm retrieving subcategories this:

  $result = mysql_query("select term_id,name,slug wp_terms term_id      in (select term_id wp_term_taxonomy parent='$cat_id'      , taxonomy='product_cat') order name asc"); 

i've tried query product details,

 $result = mysql_query("select  `id`,`post_title`,`post_content`,`guid` wp_posts post_type='product' , post_status='publish' , id in(select object_id wp_term_relationships term_taxonomy_id in('$cat_id') ,  term_taxonomy_id in(select term_taxonomy_id wp_term_taxonomy  taxonomy='product_cat'))"); 

this giving me title , description when execute in phpmyadmin when give same code in php , sending response through json giving me empty response.

i think query not proper.

kindly suggest me how product details woocommerce,am working first time.

it sounds can use standard wp_query() this:

$args = array(      'post_type' => 'product',      'posts_per_page' => -1,      'product_cat' => $cat_id,  ); $result = new wp_query( $args ); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -