WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Where is the mySQL table that stores prices of products? (4 posts)

  1. G-Olly
    Member
    Posted 7 months ago #

    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?

    https://wordpress.org/plugins/woocommerce/

  2. helgatheviking
    Member
    Posted 7 months ago #

    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' );
  3. G-Olly
    Member
    Posted 7 months ago #

    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.

  4. Grafiker29
    Member
    Posted 4 days ago #

    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.

Reply

You must log in to post.

About this Plugin

About this Topic