

WooCommerce is a popular plugin for WordPress that allows you to create and manage your own online store. However, if you want to make your store stand out from the crowd, you may need to customize the appearance and functionality of your WooCommerce pages. This is where WooCommerce templates come in handy.
WooCommerce templates are the files that control how your products, cart, checkout, and other e-commerce elements are displayed on your website. By creating and customizing your own WooCommerce templates, you can change the layout, design, and features of your store to suit your needs and preferences.
In this article, you will learn about the best practices and tips for WooCommerce template customization. By the end of this article, you will be able to create and customize WooCommerce templates like a pro.
What You Need to Know about WooCommerce Templates

WooCommerce templates determine how your online commerce components appear on your site, including products, cart, and checkout.
The template hierarchy of WooCommerce decides which template is responsible for showing the content. Understanding this hierarchy is crucial for customization. You can override the default WooCommerce templates by copying them to your theme folder and modifying them. Alternatively, you can use hooks and filters to add or remove content without touching the template files.
WooCommerce has different types of templates for different purposes, such as product templates, archive templates, cart templates, checkout templates, and email templates. Each template has its own structure and components that you can customize.
By understanding and customizing WooCommerce templates, you can create a unique and engaging online store that reflects your brand and vision.
Designing WooCommerce Templates from Scratch

To create a custom template file, you need to follow these steps:
- Create a staging environment for your site. This is a copy of your live site that you can use for testing and development purposes, without affecting your visitors or customers. A local environment is hosted on your own computer, while a staging environment is hosted on a separate server. You can use tools like WP Staging, or SiteGround’s Staging Tool to create a local or staging environment easily.
- You should create a Child template for the template you’ll be using for your site. A child template is a type of template that inherits the features and functions of another template, known as the parent template. With a child template, you can customize the appearance and behavior of the parent template without altering its original files.
When you buy a theme, you can find a child theme in the theme zip file. You just need to upload it. When you use a free theme, you may need to make a child theme yourself. Here is a documentation that explains the creation of a Child template. - Copy the template file that you want to customize from the /woocommerce/ folder in your parent theme to the /woocommerce/ folder in your child theme. Make sure to preserve the same folder structure and file name. For example, if you want to customize the WooCommerce single product page template, you should copy the file /woocommerce/single-product.php to /woocommerce/single-product.php in your child theme.
- Edit the template file in your child theme using a code editor. You can use hooks, filters, actions, and template tags to modify the output of the template. You can also add or remove HTML, CSS, or PHP code as needed. Using these elements is quite technical and one should have good coding knowledge. So, if you are not sure about doing this by yourself, we recommend hiring a professional WooCommerce plugin developer to do it for you.
- Save the template file and test it on your local or staging environment. Make sure that everything works as expected and that there are no errors or conflicts. You can use tools like Query Monitor, or Debug Bar, to troubleshoot any issues.
- Once you are satisfied with the result, you can upload the template file to your live site using an FTP. You can also use a plugin like WP Migrate Lite OR All-in-One WP Migration to sync your local or staging site with your live site.
By following these steps, you can create and customize your WooCommerce templates and make your store look and function exactly how you want. Remember to always backup your site before making any changes and to use a child theme to avoid losing your customizations when updating WooCommerce or your parent theme.
Customizing Existing WooCommerce Templates
Customizing existing WooCommerce templates involves customization. This can be done through various methods. You can make use of hooks and filters, theme customizing plugins. If you aren’t a technical person, you can opt for custom WooCommerce development who has vast knowledge in this field.
Hooks and Filters
Hooks and filters allow you to add or modify certain aspects of WooCommerce templates. Hooks provide you with specific points in the code where you can add your own functions or code snippets to change the default behavior or appearance of the template. Filters, on the other hand, are functions that enable you to modify the data or content that is passed to the template.
You can use hooks and filters to add, remove, or change any element on your online store pages such as the product title, price, add to cart button, sidebar, footer, and more. WooCommerce provides its own set of hooks which can be used to customize its functionality. You can check out these hooks and learn how to use them by visiting the documentation.
Using Action Hooks:
Action hooks are hooks that allow you to execute your own functions or snippets at a specific point in the template. For example, the action hook woocommerce_before_main_content is executed before the main content of the template is displayed. WooCommerce plugin developers use action hooks to insert your custom code before the main content, such as a banner, a slider, or a welcome message.
To use an action hook, you need to use the function add_action, which takes three parameters: the name of the hook, the name of your function or snippet, and the priority (optional). For example, to add a banner before the main content.
1 2 3 4 5 6 |
<?php function my_custom_banner() { echo '<div class="banner">This is my custom banner</div>'; } add_action( 'woocommerce_before_main_content', 'my_custom_banner', 10 ); ?> |
Using Filter Hooks:
Filter hooks are special hooks that you can use to adjust the data or content that is passed to the template. These hooks are particularly useful when you need to modify the output of a function or a piece of code. For example, the woocommerce_product_title filter hook can be used to modify the title of a product before it is displayed on the template. You can add a prefix, a suffix, or custom text to the title using this hook.
To use a filter hook, you need to use the add_filter function, which takes two parameters: the name of the hook and the name of your function or code snippet. Here’s an example of how to add a customized pricing message displaying a price with and without sale using the woocommerce_get_price_html filter hook:
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php add_action( 'woocommerce_before_add_to_cart_button', 'input_on_single_product', 1 ); function input_on_single_product() { ?> <div> <label>Message to be printed</label> <input type="text"/> </div> <?php } ?> |
Struggling with customizing your WooCommerce templates?
Get in touch with our WooCommerce Experts now!Common Customization Scenarios
Since we went through the steps for developing and customizing WooCommerce templates, it’s time to check out some of the common customization scenarios.
We’ll explore typical customization situations, such as altering product layouts, incorporating custom fields, and designing distinctive checkout pages.
We have also provided a sample code snippet below to get a better understanding.
Changing Product Layouts
Scenario: Let’s say you are a Clothes vendor. Your customers want a custom message to be printed on the cloth they are purchasing.
Use Case: Here’s a sample code that provides an input field asking the customer to enter the message to be printed. You can make use of the woocommerce_get_price_html action hook. Here’s a sample code:
1 2 3 4 5 6 7 8 9 10 11 |
<?php add_filter( 'woocommerce_get_price_html', 'highlight_sale_price', 100, 2 ); function highlight_sale_price( $price, $product ){ $product = wc_get_product( get_the_ID() ); if ( $product->is_on_sale() ) { return 'Without Sale : ' . str_replace( '<ins>', 'With Sale : <ins>', $price ); } else { return $price; } } ?> |
Adding custom fields to product pages
Scenario: Let’s say you are selling cakes online, and you want to gather more data from your clients, you have to include custom fields on your product pages.
Example: In the following code we have used the action hook “woocommerce_before_add_to_cart_button” which adds a custom text input field on the product page for customers to type in a special message:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
// Display the custom field on the product page function user_custom_field() { woocommerce_wp_text_input( array( 'id' => 'related_product_header', 'label' => 'Enter the Header Text', 'placeholder' => 'Top Related Alternatives', 'desc_tip' => 'true', 'description' => 'Enter the text to be displayed on the Header of Similar products else default text will be displayed', ) ); } add_action('woocommerce_before_add_to_cart_button', 'user_custom_field'); // Save the custom field value to the product function save_user_custom_field($product_id) { $custom_message = isset($_POST['related_product_header']) ? sanitize_text_field($_POST['related_product_header']) : ''; update_post_meta($product_id, 'related_product_header', $custom_message); } add_action('woocommerce_process_product_meta', 'save_user_custom_field'); |
Creating unique checkout pages
Scenario: You are looking to customize your checkout page by removing the default ‘Customer notes’ field from the checkout page.
Example: Here’s a sample code to remove the default field. We have used the action hook- “woocommerce_checkout_fields”.
1 2 3 4 5 6 7 8 9 10 11 |
/** * Perform custom validation during the checkout process */ function custom_checkout_validation() { // Check if the custom checkbox is selected if ( ! isset( $_POST['custom_checkbox'] ) || $_POST['custom_checkbox'] !== '1' ) { // Display an error message and prevent checkout wc_add_notice( 'Please agree to the terms and conditions.', 'error' ); } } add_action( 'woocommerce_checkout_process', 'custom_checkout_validation' ); |
WooCommerce Template File References
Here are some of the essential WooCommerce template files:
single-product.php
Role: The role of this template file is to control the layout of a single page.
Impact: This file lets you control how individual product pages are displayed. You can change the layout of your product pages, change the product appearance, and also add product-specific information.
archive-product.php
Role: The role of this template file is to control the layout of product archive pages, such as product category and
Impact: With this file, you change how the product listings are presented. You can modify pages such as product grid, and filter options.
cart.php
Role: The role of this template file is to control the layout of product pages.
Impact: This file lets you adjust the cart page which includes cart items, cart totals, and subtotal.
form-checkout.php
Role: The form-checkout.php file controls the layout of the checkout page.
Impact: This template lets you change how your checkout page will look. You can edit elements such as payment options, shipping forms, and reviews.
thankyou.php
Role: The role of the thankyou.php template file is to control the appearance of the order confirmation page.
Impact: By modifying this file, you can change the appearance of the order confirmation page and add personalized messages or extra details for customers.
my-account.php
Role: This template file controls the user account page.
Impact: This file allows you to alter the user account area, lets you provide links and additional instructions.
content-widget-product.php
Role: This template file controls the display of products within the widgets.
Impact: By modifying this template you can change the visuals of your products shown in the widgets. These include top-rated products, recent products, etc.
email header.php and footer.php
Role: These template files control the header and footer of a WooCommerce email notification.
Impact: Customizing these files lets you change the stylings of your emails, making their appearance fit your store’s style.
order-details.php
Role: With this template file you can control the order detail section within email notifications.
Impact: Editing this file lets you add custom information to order confirmation and notification emails.
quantity-input.php
Role: This template file controls the quantity input field on product pages.
Impact: By modifying this file, you can alter how the quantity input field looks and works.
Common Use Cases for Customization
WooCommerce templates are the files that determine how your online store looks and functions. By customizing WooCommerce templates, you can adapt your online store to your specific business needs and create a unique shopping experience for your customers.
Some common use cases for template customization are:
Creating a Custom Product Page
- Use case: Let’s say you want to create a unique and compelling product page layout, different from the default WooCommerce layout.
- To create a custom product page, you should customize the single-product.php template. This template controls how your product page looks and functions.
- You can edit this template in your child theme to change the design, add or remove product information, or include custom features. You can also use template hooks and filters to insert custom content where you want.
- If you opt for WooCommerce customization, professional WooCommerce website developers make use of Hooks and Filters to achieve such customizations.
Altering the cart layout
- Use case: Suppose you want to customize the look and feel of the cart your cart layout.
- The cart layout is how your online store shows the products and the total amount that the customer has to pay. By altering the cart layout, you can make your online store more user-friendly and attractive. For example, you can change the colors, fonts, or images, or add some extra information or features.
- To alter the cart layout, you should customize the cart.php template. This template is the file that controls how your cart page looks and works.
- You can edit this template in your child theme to change the design, add or remove product information, or include custom features.
Customizing Widgets
- Use case: Let’s say you are looking to customize your widgets.
- Widgets are small blocks of content that you can add to your sidebar, footer, or other areas of your website. By customizing widgets, you can change how they look and what they do. For example, you can add images, text, links, or buttons to your widgets.
To achieve this you can make use of WordPress theme customizing plugins, or make use of hooks and filters to make specific changes in the content-widget-product.php file, or you can also hire a WooCommerce development company for this job.
Recommended reading-
Wrapping Up!
So, here’s the quick scoop: making your WooCommerce store look and work just the way you want is super important. WooCommerce templates are the files that control how your online store looks and functions.
By creating and customizing WooCommerce templates, you can make your store more unique and user-friendly. You can use different methods to customize WooCommerce templates, such as using plugins, theme customizers, block editors, page builders, or code editors. You should always follow the best practices and back up your website before making any changes.
With these tricks, you’re all set to make your online shop stand out in the online world.