Override default Comparison Set template

Sometimes you may want to make changes to you Comparison Set template file in order to display custom information. Here are the steps to do so.

1

Find your "template_options"

The first thing you want to do is find your "template_options" in an existing Comparison Set's debug area.

To do this, go to a product on your site which has a Comparison Set. Under the Comparison Set, click the View Debug link. In the long debug section (underneath the list of products), you will see various $data. Look for the section that looks something like this:

[template_options] => Array
	(
		[0] => /home/username/public_html/wp-content/themes/storefront/dfrcs-templates/wc_single_product_page.php
		[1] => /home/username/public_html/wp-content/themes/storefront/dfrcs-templates/default.php
		[2] => /home/username/public_html/wp-content/plugins/datafeedr-comparison-sets/templates/default.php
	)
Viewing template_options of a Comparison Set
2

Identify the new path

In the template_options you have 3 paths (indexed 0, 1, 2). The Comparison Set plugin will attempt to load those template files in the order in which they appear.

That means the Comparison Set plugin will first look for this file:

/home/username/public_html/wp-content/themes/storefront/dfrcs-templates/wc_single_product_page.php

If it can't find that it will look for this file:

/home/username/public_html/wp-content/themes/storefront/dfrcs-templates/default.php

If it can't find that, it will load the default file which can be found here:

 /home/username/public_html/wp-content/plugins/datafeedr-comparison-sets/templates/default.php

In most cases, you will copy the 2nd path (indexed by [1]). So we will use this path:

/home/username/public_html/wp-content/themes/storefront/dfrcs-templates/default.php
3

Create a new directory in your theme's folder

Now you will create a new directory in your theme's folder named dfrcs-templates. So if you are using the Storefront theme, you will have this new directory:

/home/username/public_html/wp-content/themes/storefront/dfrcs-templates/

Important

Since you are modifying your theme's directory, you MUST create a child theme otherwise all of your changes will be deleted the next time you update your theme.

4

Copy default.php file to new directory.

Now you need to add the template file to your new directory. Make a copy of the this default.php file found here:

/home/username/public_html/wp-content/plugins/datafeedr-comparison-sets/templates/default.php

Move that new default.php file to your new directory so that you have the following file:

/home/username/public_html/wp-content/themes/storefront/dfrcs-templates/default.php
5

Make your edits

Now that you have a new default.php file here:

/home/username/public_html/wp-content/themes/storefront/dfrcs-templates/default.php

You can now start editing your file.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us