1

I am using WordPress 4.7.4 and WooCommerce 3.0.5.

I updated _sale_price, _price, _regular_price using meta_id with code below:

   $meta_tbl = $wpdb->prefix.'postmeta';
   foreach ($_POST['loop'] as $loop_k => $loop_v) {
        $wpdb->update(
            $meta_tbl,
                array( 'meta_value' => $loop_v['price'] ),
                array( 'meta_id' => $loop_v['price_meta_id'] ),
                array( '%d' )
            );
        $wpdb->update(
            $meta_tbl,
                array( 'meta_value' => $loop_v['regular_price'] ),
                array( 'meta_id' => $loop_v['regular_price_meta_id'] ),
                array( '%d' )
            );
        $wpdb->update(
            $meta_tbl,
                array( 'meta_value' => $loop_v['sale_price'] ),
                array( 'meta_id' => $loop_v['sale_price_meta_id'] ),
                array( '%d' )
            );
  }

But still the shop page is displaying the old price of products! How can I do it properly?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Prafulla Kumar Sahu
  • 9,321
  • 11
  • 68
  • 105

1 Answers1

2

Try by adding this line after your code.

wc_delete_product_transients( $post_id );

// $post_id replace with product ID

mujuonly
  • 11,370
  • 5
  • 45
  • 75