Black Friday Sale Ends in

0Days

0Hours

0Minutes

0Seconds

View Deals

Use Coupon Code BF2024

×
WooCommerce Template Override

Feb 15, 2024 | Blog

How to Override WooCommerce Templates in Your WordPress Child Theme

Overriding WooCommerce templates in your WordPress child theme allows you to customize the appearance and functionality of your store without making direct changes to the WooCommerce plugin. This approach is recommended to ensure your customizations remain intact and your site remains update-safe. 

We recommend not doing this because you can usually make changes with hooks (filters and actions). It’s a safer approach for small tweaks and ensures better compatibility with WooCommerce updates. But you might have to change the template if there’s no hook for what you need. Here’s how to achieve this:

Understand WooCommerce Template Structure

The default WooCommerce templates are in the WooCommerce plugin directory under wp-content/plugins/woocommerce/templates/. These templates control various parts of your WooCommerce store, like product, cart, and checkout pages.

Create a WooCommerce Folder in Your Child Theme

To override a template, create a woocommerce folder in your Child Theme’s directory. The path will be wp-content/themes/your-child-theme/woocommerce/.

Copy the Template File to Your Theme

Find the template file in the woocommerce plugin folder you want to override. Copy it into the same place inside the woocommerce folder of your child theme. Make sure the folders inside your child theme’s woocommerce folder look just like they do in the WooCommerce plugin. For example, to override the single product page, copy ‘single-product.php’ from ‘wp-content/plugins/woocommerce/templates/’ to ‘wp-content/themes/your-child-theme/woocommerce/’.

Edit the Copied Template File

Open the template file you copied into your child theme’s woocommerce folder. Change it per your requirements, such as editing the HTML or adding/editing PHP code. Make sure not to remove any WooCommerce hooks in the file unless you plan to change those.

Review Your Changes

After saving your changes, visit your website to see the effects of your modifications. Make sure that your changes do not break any functionality and that the appearance is as expected.

Keep Your Overrides Up to Date

Whenever WooCommerce releases a new version, check if any of the templates you’ve overridden have been updated. If so, you may need to apply these updates to your customized templates to ensure compatibility and functionality with the latest version.

Best Practices

  • Backup your site Take the backup before making changes to templates.
  • Document your changes so you or someone else can understand what was done and why, which is helpful for future maintenance.
  • Test your site thoroughly after making changes, including checking for mobile responsiveness and cross-browser compatibility.

Following the steps above, you could effectively customize your WooCommerce store to match your requirements.

Posted By:
Arif
Development Head at Elicus and has over 13 years of experience in the WordPress development industry.

1 Comment

  1. Fotowoltaika

    Thanks for that. I need this solution to place templates in my child theme.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

1 Comment

  1. Fotowoltaika

    Thanks for that. I need this solution to place templates in my child theme.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

11 Email Marketing Plugins for WordPress That Make Sense

11 Email Marketing Plugins for WordPress That Make Sense

If you’re looking for an email marketing plugin for WordPress, then you have landed on the right page. In this post, we have curated a list of the 11 best WordPress email marketing plugins available for free and paid. Using one of the listed plugins, you can easily...

WPMozo Black Friday Sale

Explore, Learn, Grow: Join Now!

Black Friday Popup