In single product page i want to display the stock quantity of all products that have the same value in a custom field (base_number) and i assume that this would be possible by taking the ids of these products.
What i've tried without any luck
$product = wc_get_product( $product_id );
$same_base = get_posts( array(
'post_type' => 'product',
'post_status' => 'publish',
'meta_key' => 'base_number',
'meta_value' => get_post_meta(get_the_ID(), 'base_number', TRUE),
'fields' => 'ids',
));
return $same_base;
Any help would be much appreciated.