i create custom function to get all data of product to one category in functions.php
function get_products()
{
$cat_id = $_POST['category'];
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => '12',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id', //This is optional, as it defaults to 'term_id'
'terms' => $cat_id,
'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
),
array(
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => 'exclude-from-catalog', // Possibly 'exclude-from-search' too
'operator' => 'NOT IN'
)
)
);
$wc_query = new WP_Query($args);
if ($wc_query->have_posts()) :
while ( $wc_query->have_posts() )
$wc_query->the_post();
var_dump($product->get_regular_price());
endwhile;
endif;
//echo json_encode($products);
wp_die();
}
the result is string(0)"" to the price
what is the mistake???