How to upgrade WooCommerce Database for all sub-sites?

I noticed that once in a while WooCommerce updated will need to manually click the "Run the updater" and all sub-sites need to do it separately. Any idea how can network super admin can upgrade all at once?

  • Adam
    • Support Gorilla

    HI iamJayChong

    I hope you’re well today and thank you for your question!

    This is related to the WooCommerce settings/db updates only as the plugin itself is updated “everywhere” (since there’s only one install on the Multisite, even if it’s separately activated on sub-sites). However, it’s the way the plugin works and there’s no “out of the box” solution.

    There’s a plugin that used to help with this but it wasn’t update for 7 years already so I wouldn’t recommend it. There is another solution though that does seem to work fine but the downside is it will only be useful if you do have shell (SSH) access to the server and there’s WP-CLI available. If yes, then here’s a nice write-up on how to do this (along with a bash script to “automate” the task):

    https://guides.wp-bullet.com/automate-woocommerce-database-upgrade-process-for-single-and-multisite/

    I think it could also be possible to automate that with some custom script that could be run directly from network-admin but that’s an assumption as I’m not that much familiar with WooCommerce code/API. If there is a way to do it, I’m afraid it would have to be custom coded for you anyway as I didn’t find any ready to use tool that would do this.

    Best regards,

    Adam

  • splaquet
    • WordPress Warrior

    I don’t believe that this is the solution that you’re looking for, but these WP-CLI commands have become my goto solutions:

    here’s my WPMU update:

    wp core update; wp core update-db --network; wp cache flush --network; wp theme update --all; wp plugin update --all; wp cache flush --network; \
    wp site list --field=url --allow-root | xargs -n1 -I % wp --url=% plugin update --all; wp site list --field=url | xargs -n1 -I % wp --url=% cron event run --due-now; wp site list --field=url | xargs -n1 -I % wp --url=% rewrite flush;\
    wp site list --field=url | xargs -n1 -I % wp --url=% cache flush --all --async;

    and to follow up for WPMU installs w/ Woo:

    wp site list --field=url | xargs -n1 -I % wp wc tool run db_update_routine --url=% --user=<admin_username>;\
    wp site list --field=url | xargs -n1 -I % wp --url=% action-scheduler run --force; \
    wp cache flush --all --async --network && wp site list --field=url | xargs -n1 -I % wp --url=% cache flush --all --async

    while it’s not idea, you can take snippets of this and add them into system crons.