Use WooCommerce shortcodes to Displaying Products across Shops
This newly implemented functionality helps with displaying WooCommerce Products across shops, in the network, under your WordPress MultiSite environment. Promote specific products, types of merchandise, category of goods, so boosting overall network sales. The new function is available as a Woocommerce Product Shortcode and is easy to implement. Any section of a site can include the shortcode to output the required products. The woocommerce shortcode is usable within the default WordPress editor ( classic ) or any advanced layout composer like Elementor, Divi, Visual Builder etc.
Which are the woocommerce shortcodes to use?
Using the default WordPress block editor, chose the Shortcode widget:
In the widget insert the woogc_products which is the new woocommerce product shortcode that provides the functionality:
This takes multiple arguments, for the outputted woocommerce products, to match the exact requirements:
- sites_id – The network sites IDs intended for use in the shortcode filtering criteria when outputting the products.
- categories – The used category name.
- search – A keyword search used for filtering the products title, content, excerpt etc.
- min_price – A minimum price for the products.
- max_price – A maximum price for the products.
- orderby – The order of returned products.
- status – The Status of returned items, as default being Publish.
- posts_per_page – The number of items returned for current page.
- page – The number of page, is using above argument limitation.
All of above shortcode arguments are optional.
Example of woocommerce shortcode usage.
To outputs products on current shop, from network sites ID 3 and 4, using the word book, invoke the following woocommerce shortcode:
[woogc_products sites_id=3,4 search=book]
A sample output of the shortcode appears like this:
How does the displayed shared woocommerce products layout look like?
For better integration with the current layout, the outputted data uses the local site theme appearance and styles. Further customization is possible, if necessary. Therefore through the template file that holds the processor unit, similar to WooCommerce templates.
When displaying the WooCommerce Products across shops, the plugin core uses the template located at /wp-content/plugins/woo-global-cart/templates/shortcodes/woogc-products.php. This file is based on the WooCommerce default loop template. So the result is a basic layout, always using the theme appearance and style.
If need customization, the above file need copied over to theme/child-theme, within /woocommerce/shortcodes/. After that, the required adjustments can apply to the new file.