0

I have a Script that uploads/updates products into my WooCommerce website programmatically from of a JSON file.

Script is used to update product variations as well.

I am using Wordpress's built-in functions to insert/update POSTS or POSTS_METAS

Everything is working perfectly, I can see variant prices are being updated fine.

But only thing that is not working is the price range displayed under title of a product enter image description here

This range is actually the

lowest price of a variant - highest price of a variant

It only gets updated if I press the blue colored "UPDATE" button from admin area.

I also tried doing(after inserting/updating all variants)

wp_update_post(array(
    'ID'    =>  $post_id,
    'post_status'   =>  'publish'
    ));

But had no luck.

Umair Ayub
  • 19,358
  • 14
  • 72
  • 146
  • Possible duplicate of [Add sale price programmatically to product variations](https://stackoverflow.com/questions/41547590/add-sale-price-programmatically-to-product-variations) – Umair Ayub Jun 23 '17 at 10:44

1 Answers1

0

Turned out those prices are also cached in transient wp_options table.

So, I've find solution that worked for me:

wc_delete_product_transients($post_id);
Umair Ayub
  • 19,358
  • 14
  • 72
  • 146