T.Newman
T.Newman

Reputation: 89

WooCommerce multisite, sharing products

I'm trying to combine a set of existing WooCommerce installs into one, to help running them all a lot easier.

In the current set up, there is:

It looks like the current set up of multistore on woocommerce was not built for this purpose. It is currently designed for an "Etsy type" shop, with multiple vendors, each with their own shop, with its own products. I want a single vendor, with multiple shops, selling from a shared set of products.

In the very near future, there is going to be a need for international sites. These would be copies of the other sites, in different languages, with different domains. So, ideally, whatever solution I arrive at, would allow for this.

From what I have found so far, a multisite WordPress install, with WooCommerce, and one of the following plugins seems like the best idea:

At this point, I really feel like I have overcomplicated this, and I thought this would be a much more common requirement. Have I missed, or misunderstood, a part of woocommerce or multisite that would let me do this? Is this the "right way" to do this?

Most of my research was in threads that ended with no real answer, so if nothing else, I wanted to consolidate what I've found, in case anyone else is trying this!

Upvotes: 3

Views: 2768

Answers (1)

Misha Rudrastyh
Misha Rudrastyh

Reputation: 883

Though this is an old question, it still has no replies and probably my answer will be helpful to someone.

Everything depends on whether you're going to use a shared cart and orders for your products or not.

If you're not going to have this kind of functionality then all you need to do is just to crosspost specific products to appropriate websites.

If we consider using a plugin, I would recommend to take a look at this one: https://rudrastyh.com/plugins/simple-multisite-crossposting

If we consider using the code approach:

  1. We need to use woocommerce_update_product action hook which is going to be triggered every time a product is updated or created on a master store
  2. When depending on a product category I guess we can switch to a specific store and create a product copy there, that's it.

Code example:

add_action( 'woocommerce_update_product', function( $product_id, $product ) {

    // also don't forget to remove_action here otherwise it will be looped
    // remove_action( 'woocommerce_update_product' ...
    
    // so we switch to a specific store ID
    switch_to_blog( 2 );
    
    // and create a product there
    $new_product = new WC_Product_Simple();
    // set product information
    $new_product->set_name( $product->get_name() );

    // ...

    $new_product->save();

    // coming back to a current blog
    restore_current_blog();

}, 20, 2 );

I took the code from here: https://rudrastyh.com/woocommerce/multisite-product-sync.html#creating-products

Upvotes: 1

Related Questions