Skip to content
Advertisement

Update all variations prices of a variable product in Woocommerce

I need to get all variation id and update price in loop. Simple query and loop looks like:

JavaScript

I think not working this:

JavaScript

or this:

JavaScript

Advertisement

Answer

First in your code or should be replaced by '. Also if used $post-ID should be replaced by $post->ID

Depending on where and how you are using this code, you should try to include global $post; first to be able to use the WP_Post object $post.

Then you could try to use this customized version of your code instead:

JavaScript

This code is tested on WooCommerce version 3+ and works

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement