woocommerce-external-product-embed
woocommerce-external-product-embed copied to clipboard
Pull data from multiple woocommerce sites?
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?
Definitely possible, but will require some hacking to the core plugin.
-
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.
-
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_Clientclass here: https://github.com/WPprodigy/woocommerce-external-product-embed/blob/dc69e4840f67014593a9c42d9483d6dd7f4941bf/classes/class-wcepe-data-store.php#L64 -
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