Support » Plugin: WooCommerce » another product variations issue

  • Resolved chynanccu

    (@chynanccu)


    I made the most recent update to woocommerce…. system status says that my wc version is 2.4.3 and my wc database version is 2.4.3. I am on version 4.2.4 of wordpress.

    Yesterday, I realized that my site was saying that all of my products were out of stock.

    I updated my virtue theme to 2.5.2 as instructed by Kadence. (in response to WC most recent update)

    My products have variations, so if you click on one of my products and try to select the variations and add to cart it does not work properly. It gives error “please choose product options”

    I have spoken with the support team for Virtue themes (kadence), and this is what he came up with (this is his email response to me):
    “So I activated a different theme. You have the same problem. The variations database didn’t seem to update. My guess is if your tried to run it before the server doesn’t have the power to run through all those variations. (the server seems really slow)

    I made a test product which works to confirm that is is an issue with the attributes not updating.

    At this point. I suggest contacting woocommerce and asking if there is a way for you to re-run the database update.

    You can activate a standard theme if they want to show this isn’t a theme issue.”

    I am losing money… is there any way you can help me?

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Claudio Sanches

    (@claudiosanches)

    You can try force run the update with:

    function force_wc_update_attributes() {
    	global $wpdb;
    
    	// Select variations that don't have any _stock_status implemented on WooCommerce 2.2
    	$update_variations = $wpdb->get_results( "
    		SELECT DISTINCT posts.ID AS variation_id, posts.post_parent AS variation_parent
    		FROM {$wpdb->posts} as posts
    		LEFT OUTER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id AND postmeta.meta_key = '_stock_status'
    		WHERE posts.post_type = 'product_variation'
    		AND postmeta.meta_value IS NULL
    	" );
    
    	foreach ( $update_variations as $variation ) {
    		// Get the parent _stock_status
    		$parent_stock_status = get_post_meta( $variation->variation_parent, '_stock_status', true );
    
    		// Set the _stock_status
    		add_post_meta( $variation->variation_id, '_stock_status', $parent_stock_status ? $parent_stock_status : 'instock', true );
    
    		// Delete old product children array
    		delete_transient( 'wc_product_children_' . $variation->variation_parent );
    	}
    
    	// Invalidate old transients such as wc_var_price
    	WC_Cache_Helper::get_transient_version( 'product', true );
    }
    
    add_action( 'init', 'force_wc_update_attributes' );
    

    Try run this one time.

    Can you please tell me where I should place this at? I don’t want to screw up my site any worse?

    Plugin Author Claudio Sanches

    (@claudiosanches)

    @chynanccu where you want, you can add this to your theme functions.php or do better and write a plugin for it.

    Hey Chynanccu

    Was having the same issue as of this morning and think I may have found the issue. It seems the update requires your site to run a higher version of php, whatever that means. It’s explained here.

    http://docs.woothemes.com/document/how-to-update-your-php-version/

    I only found this solution because of the comment the dude who supports your them made. Sounds like it’s an incompatibility issue between WC and your host so you got to get your host to fix it.

    As a workaround, I noticed that if I decreased the number of variations (20 was the max that seemed to work) products returned to showing correctly as in stock. Hope that helps

    @mymainmanpat – I wish I could buy you a beer. THANK YOU! You have been far more helpful than woo or kadence. I am deeply appreciative. Removing a variation fixed it for me. Thanks a MILLION!

    @Intellexual that would be nice but unfortunately the update I ran that I thought would fix the problem did not. My website will still operate if I cut my variations down to 20 but i would like to be able to sell the full arsenal of 32. If you by chance found a solution or do so in the future I would much appreciate an update to the thread I started below.

    https://wordpress.org/support/topic/too-many-product-variations-causing-out-of-stock-message?replies=1#post-7311485

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘another product variations issue’ is closed to new replies.