WooCommerce get All Products
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
function get_wc_subcategories($parentID){
$taxonomy = 'product_cat';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 2; // 1 for yes, 0 for no
$title = '';
$empty = 0;
$args3 = array(
'taxonomy' => $taxonomy,
'child_of' => 0,
'parent' => $parentID,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title,
'hide_empty' => $empty
);
$arr=array();
$sub_cats3 = get_categories( $args3 );
if($sub_cats3) {
foreach($sub_cats3 as $sub_category3) {
$arr[]=array('name'=>$sub_category3->name,'slug'=>$sub_category3->slug,'term_id'=>$sub_category3->term_id,'url'=>get_term_link($sub_category3->slug, 'product_cat'));
}
}
return $arr;
}