woocommerce-external-product-embed icon indicating copy to clipboard operation
woocommerce-external-product-embed copied to clipboard

Pull data from multiple woocommerce sites?

Open tonyr101 opened this issue 6 years ago • 1 comments
trafficstars

Is it possible to pull product data from more then 1 source?

I have 3 wordpress / woocommerce sites and would like to add the latest products from all three onto a 4th wordpress site... They would need to be seperate so I can display them on different pages etc (site A products on page1, site B products on page2 etc)

How easy would this be?

tonyr101 avatar Feb 28 '19 19:02 tonyr101

Definitely possible, but will require some hacking to the core plugin.

  1. Add a shortcode attribute where you can pass which store (url or ID perhaps) that you want to get product from, and return it in the query_args: https://github.com/WPprodigy/woocommerce-external-product-embed/blob/dc69e4840f67014593a9c42d9483d6dd7f4941bf/classes/class-wcepe-shortcodes.php#L120.

  2. You'll then need to make changes to the data store so it knows how to save transients based on which store the products belong to. This class also needs to pass along which store you are querying for into the WCEPE_API_Client class here: https://github.com/WPprodigy/woocommerce-external-product-embed/blob/dc69e4840f67014593a9c42d9483d6dd7f4941bf/classes/class-wcepe-data-store.php#L64

  3. In this API Client class, you can add a constructor that accepts this store information and then conditionally sets the API keys depending on which store you want to query from: https://github.com/WPprodigy/woocommerce-external-product-embed/blob/dc69e4840f67014593a9c42d9483d6dd7f4941bf/classes/class-wcepe-api-client.php#L27-L38

WPprodigy avatar Feb 28 '19 22:02 WPprodigy