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 categories ( comma separated names ).
- categories_exclude – Exclude specific categories ( comma separated names ).
- 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.
- disable_pagination – Disable pagination for the shortcode list.
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:
Specify categories names that include the products to output:
[woogc_products categories=”books, art”]
How does the displayed shared woocommerce products layout look like?
For perfect integration with the current site layout, the outputted data uses the shop theme appearance and styles. If necessary, further customization is possible. Therefore the template file that holds the processor unit is editable, 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 current shop 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 newly copied file. On further plugin updates, the current template file remains as is. So no changes will be lost.