1. Home
  2. Documentation
  3. WooCommerce Product Table
  4. Advanced Usage
  5. Adding product tables to the WooCommerce shop page, category archives & search results

Adding product tables to the WooCommerce shop page, category archives & search results

WooCommerce Product Table is primarily designed to be used by adding a shortcode to standard pages or posts. However, you can also display it in your shop by overwriting the relevant WooCommerce template file in your theme.

For example, you can add a product table to the main shop page or product category pages – replacing the usual store layout provided by WooCommerce.

The instructions on this page will add the product table layout to all of the following pages in your store:

  • The main shop page
  • The product category and product tag archive pages
  • Any custom product taxonomy archives
  • The product search results page

If you want to show it on some templates but not others (e.g. the search results page but not the main shop page), then this will require custom coding that is outside the scope of under our plugin support.

Please note that this code is aimed at developers and if you don’t know how to use it then you should ask your developer. If you don’t have one, we recommend posting a job on Codeable.

WordPress plugin customizations service

How to add product tables to the shop page, categories, taxonomies and product search results

1. First create a folder called “woocommerce” in your theme or child theme. If your theme already has this folder, you can skip this step. Upload the folder to your server in this location:

/wp-content/themes/<your theme>/woocommerce/ 

2. Next, download the our sample archive-product.php template (see table below), and upload it to the /woocommerce/ folder you just created. It should be in this location:

/wp-content/themes/<your theme>/woocommerce/archive-product.php

Download the archive-product.php file based on your current setup:

Scenario File
I’m using the latest version of WooCommerce (3.3 or later) DOWNLOAD
I’m using WooCommerce 3.2 or earlier DOWNLOAD
I’m using the Flatsome theme DOWNLOAD
  • If you need more information on WooCommerce templates, please refer to the WooCommerce documentation.
  • The template is also included in the plugin folder under the /templates/ directory.

You should now see product tables displayed on your main WooCommerce shop page, category pages and elsewhere in your store.

If you don’t see a product table, check the following:

  • Is the correct theme active? If you have uploaded your template to the child theme (e.g. flatsome-child) but the parent theme is active, then your template won’t be picked up. In this case you would need to activate the child theme.
  • Does your theme have a file called ‘woocommerce.php’? It will be in the theme’s root folder, i.e. /wp-content/themes/<your theme>/woocommerce.php. If so, this file will override the archive-product.php template (and any other template), so it won’t work. To fix this you will need to delete or rename the woocommerce.php file.
  • Do you have a caching plugin? Sometimes this can prevent the new template from being picked up. Try disabling the caching plugin temporarily or clearing the cache.

How to configure the product table

If you inspect the sample template file, you’ll see that line 60 sets the product table shortcode:

$shortcode = '[product_table columns="image,name,price,add-to-cart"]';

You can add additional shortcode options (and change the columns option) as you would with the shortcode on a regular page.

For example, if you wanted to add the sort_by and show_quantity options, you would change this line to:

$shortcode = '[product_table columns="image,name,price,add-to-cart" sort_by="price" show_quantity="true"]';

Please see this article for the full list of shortcode options.

Using filter widgets on the shop page, categories and taxonomy archives

WooCommerce Product Table comes with its own set of product filter widgets which you can add to a widgetized area such as a sidebar. These only work for product tables on normal pages and posts. They do NOT work for product tables that have been added directly to the shop page, category pages etc.

To use filter widgets on these pages, you need to use the built-in WooCommerce filter widgets instead of the dedicated product table widgets. You can find these in Appearance > Widgets. They start with ‘Filter Product by’ instead of ‘Product Table’ (see screenshot).

FAQ

Can I use a different shortcode for each category?

The above instructions assume that you’ll have the same shortcode for each category. To dynamically use different shortcodes depending on the current category, you would need to do some extra custom coding.

This is outside the scope of our standard plugin support. If you don’t know how to do the required coding, then we recommend that you post a job on Codeable where one of their WordPress experts can quote for the work.

Can I add the product table layout to some categories but not others?

The sample template provided above will add the product table layout globally throughout your store. Some people like to use the product table on specific categories only. For example:

  • You might be creating a WooCommerce wholesale store and want to use product tables to add a wholesale order form to your B2B categories only.
  • You might be using WooCommerce Product Table with WooCommerce Protected Categories and want to add product tables to your protected category pages only.

To just show the product table layout on protected categories, you would need to add some custom code to the archive-product.php template. If you want to specify which categories should have the product table layout then you will need to reference these categories in the template. If you are using WooCommerce Protected Categories and want to add product tables to your protected categories, then you can use these instructions as a starting point.

For a more advanced search, some people like to use WooCommerce Product Table with a third party search plugin such as Relevannsi or the official WooCommerce Product Search or Product Finder plugins which have extra features such as advanced search filters and instant results. You can do this by customizing the search results template for the search plugin to include the product table layout.

The sample template above is a good starting point to help you with this. However, this is an advanced task and is not covered by our plugin support. If you don’t know how to do it then you will kneed to ask a developer to do it for you, or post a job on Codeable.

Can I use product tables on the main WordPress search results?

The above instructions will use the product table layout on the product search that comes with WooCommerce. It will not work on the WordPress search box for your whole website. This is because the sitewide search results include other types of content (such as pages and posts), and WooCommerce Product Table can only list products.

If you want to create a table view for your sitewide search results, then you can do this with our other table plugin, Posts Table Pro. This lists all types of WordPress content in a table, instead of just products. (Instructions for Posts Table Pro here.)

 

Was this article helpful?

Related Articles