Prices are stored as post meta so they are in the wp_postmeta
table (assuming your prefix is wp). The post_id
will correspond to the post/product ID number and the meta keys would be _regular_price
and _sale_price
.
You could also run something like this from a plugin (or even your theme’s functions.php since it will only be run once):
This is untested, so use at your own risk.
function kia_run_once(){
// if the transient doesn't exist then we need to run the function once
if ( false === ( $all_products = get_transient( 'kia_update_products_once' ) ) ) {
$all_products = new WP_Query( array( 'post_type' => 'product' ) );
if ( $all_products->have_posts() ) :
while ( $all_products->have_posts() ) : $all_products->the_post();
$post_id = get_the_ID();
// update the post meta to whatever you'd like
update_post_meta( $post_id, '_regular_price', '' );
update_post_meta( $post_id, '_sale_price', '' );
endwhile;
endif;
set_transient( 'kia_update_products_once', 1 );
}
}
add_action( 'admin_init', 'kia_run_once' );
Thread Starter
G-Olly
(@g-olly)
That’s great thanks Helga for the insight. I might test that on the test site before I implement that on the production site though. Will let you know either way. Thanks again.
Hi Helga
I am also trying to access the prices but cannot see them. I have clicked on wp_postmeta and then on post_id but cant see any prices.