Woocommerce override template files via theme in wordpress

By

August 8, 2013WordpressNo comments

Woocommerce override template files via theme is pretty straight forward. This plugin has lot of features to utilize for e-commerce websites. Woocommerce template contains the markup and template structure for the front end display.

Introduction

Woocommerce is a WordPress ecommerce plugin that helps us to build an online store using wordpress platform. Woocommerce is an efficient, robust plugin that is built using wordpress best practices.

When to override templates?

We must be clear on when to override the template, in real time if you want to change the default Woocommerce listing of product listing in all product page, then you should go for override templates. If you want to just change the color of texts or size of texts then there is no need for overriding the template file, you just need to write a CSS rule to override it.

Advantage of overriding woocommerce templates:

  • Plugin upgrade safe.
  • Clean code
  • View files in separate structure, so that plugin functionality will not hang up.
  • Easy understanding.

Steps to Override a template in woocomerce plugin.

Step 1 : Navigate to your current theme folder structure which will be located in wp-contents/themes/CURRENT_THEME/

Step 2 :  Create a folder under your current theme directory called “woocommerce”

Step 3 : Create template files for which you need to change the layout and place it under “woocommerce” directory,

for eg:-

  1. archive-product.php
  2. content-product.php

Step 4 : Change the layout or HTML markups inside the above files to see the change in products listing page and product landing page.

Step 5 : If the change is not reflected clear the browser cache.

Similarly you can do for all the templates under woocommerce directory from wp-content/plugin/woocommerce. Just copy paste the whole files under template directory at wp-contents/themes/CURRENT_THEME/woocommerce so that all files will be referenced from themes directory instead of plugin directory.

For more information refer this link woocommerce documentation.

Leave a Reply