Get all variations id & update price
-
Hi! I need to get all variation id and update price in loop.
Simple query and loop looks like:$params = array(
‘posts_per_page’ => -1,
‘post_type’ => ‘product_variation’,
‘post_parent’ => $product->get_id() // tried $post-ID
);
$variations = get_posts( $params );
foreach ( $variations as $variation ) {
$variation_ID = $variation->ID; // tried $post-ID, $product->get_id()
$regular_price=34;
update_post_meta( $variation_ID, ‘_regular_price’, (float)$regular_price );
update_post_meta( $variation_ID, ‘_price’, (float)$regular_price );
}I think not working this (‘post_parent’ => $product->get_id()) ot this($variation_ID = $variation->ID;). Can you help with this
The page I need help with: [log in to see the link]
The topic ‘Get all variations id & update price’ is closed to new replies.