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 *

WooCommerce User Roles and Capabilities: A Complete Guide

WooCommerce User Roles and Capabilities: A Complete Guide

WooCommerce allows flexibility to all kinds of websites. User roles and their permissions are one example of this. A website can have roles for Authors, Editors, and the obvious Site Admin. The capabilities of these user roles vary. The site admin is the only one who...

How to Display WooCommerce QR Code (5 Easy Steps)

How to Display WooCommerce QR Code (5 Easy Steps)

A QR code enables users to access detailed information about anything with a simple scan. Whether it is marketing or transactions, companies have been using these square-shaped textures to simplify accessing additional information. In WooCommerce’s context, displaying...

Best WooCommerce Plugins on Sale | Flat 40% OFF

Best WooCommerce Plugins on Sale | Flat 40% OFF

Our Black Friday sale will end soon, and with that, the biggest discount of the year on the best WooCommerce plugins will be gone.  All the great plugins and widgets will be available at the original price and probably cost more with additional features...

WPMozo Black Friday Sale

Explore, Learn, Grow: Join Now!

Black Friday Popup