Support » Plugin: WooCommerce » Where is the mySQL table that stores prices of products?

  • Hi There,

    I’m looking to remove prices for all 2000 of my products. This would take an eon to do via the wordpress dashboard i.e. edit product, remove price, update product, repeat… All I want is to find the table and column in the mySQL database that stores the pricing so that I can delete it from there saving me a lot of time. Can someone please point me in the right direction?

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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', '' );
    	    set_transient( 'kia_update_products_once', 1 );
    add_action( 'admin_init', 'kia_run_once' );

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Where is the mySQL table that stores prices of products?’ is closed to new replies.