I'm creating a plugin to create reports for a WC multisite installation.

I would like to be able to use the plugin in the master site admin and get orders for all sites within the multisite installation.

I don't see a way to do this in the wc_get_orders WC function or any other documented way. Is this possible using the WordPress or WooCommerce APIs?


The answer is to call the switch_to_blog($blog_id) function before calling any WooCommerce functions, then restore_current_blog() once done.

  • hi mark i would be really interested to see this plugin in action do you have an example – Brad Holmes Dec 26 '17 at 20:28
  • switch_to_blog() doesn't give you access to Woocommerce functions unless you have Woocommerce installed on the current site as well, FYI. – Nathan Jul 30 '19 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.