How to update WooCommcerce templates with diff checker

· woocommerce · 2 min read, Steve Monsen

Updating custom WooCommerce templates can be a pain. This tutorial will show you how to use a diff checker to make it easier.

Background

When WooCommerce updates, it requires that any customized WooCommerce templates that have been placed in the theme’s directory be updated as well. This can be a pain, especially if the template has been heavily customized.

woocommerce-template-update-warning.png woocommerce-template-override-list.png

I recently updated a custom WooCommerce template. The template was originally created by a third-party developer and it was a bit of a mess. I needed to update the template to work with the latest version of WooCommerce by meticulously migrating changes to the template to the new WC template version. The template was located in the theme’s directory at /theme-name/woocommerce/cart/cart.php.

Most of the time, there are only a few changes that need to be made to the custom WC templates. A quick visual scan of the file is usually enough to identify the changes that need to be made.

When that is not the case, though, and many changes have been made to the template, it can be difficult to identify the changes that need to be made. In these cases, a diff checker can be used to identify them.

How to use a diff checker to update a WooCommerce template

  1. Make a backup of the template file from the theme’s /woocommerce/ directory to a temporary location.
  2. Open the existing template in question into an editor (VS Code, Sublime, etc.).
  3. Open the new version of the template file in wp-content/plugins/wooocommerce/templates into an editor.
  4. Navigate to an online diff checker such as Diff Checker or Diff Now. (Keyword search “online diff checker” to find more.)
  5. Copy the contents of the existing template file into the left pane of the diff checker.
  6. Copy the contents of the new template file into the right pane of the diff checker.
  7. Click the Find Difference button (or equivalent in another tool).

The diff checker will highlight the differences between the two files. Make the necessary changes to the existing template file to match the new template file.

I’ve found this to be faster than trying to use Git diff or something like that. Online diff checkers are more convenient for one-off tasks like this, in my experience.

References

Back to Blog