Woocommerce is increasingly becoming the eCommerce platform of choice for most new websites since it is not only easy to use but there are numerous freely available wooCommerce themes. In order to improve your wooCommerce development there are several code snippets that make it easier for developers building or customizing wooCommerce themes.

From my experience, there are many snippets you can use to customize wooCommerce but the code snippets below have proven to be very useful and time saving for my projects. I would like to share with you these snippets as the best WooCommerce snippets.

Best WooCommerce Snippets

The following code snippets should help you customize the WooCommerce functionality and form. These code snippets should help you to remove or add functionality to WooCommerce.

1) Declare WooCommerce support in third party theme

The first most useful code is used for declaring WooCommerce support in your theme. This is a very important snippet that you can use to add WooCommerce support to any WordPress theme.

2) Adding Custom Currency to WooCommerce

WooCommerce by default To add a custom currency in WooCommerce 2.0+, copy and paste this code in your theme functions.php file and swap out the currency code and symbol with your own. After saving changes, it should be available from your WooCommerce settings.

3) To display the cart contents and total in your template

If you want to show the cart content and the total in your template you should use something like this:

4) Change number of thumbnails per row in product galleries

I always want to change the thumbnail displayed per row in product galleries, I often use this code to change the display per row.

5) Add a new country to countries list

To add a new country to the countries list, use this snippet (you can paste it in the functions.php file within our theme folder):

6) Display My Account link in a template file

Displays a link to the user account section. If the user is not logged in the link will display ‘Login / Register’ and take the use to the login / signup page. If the user is logged in the link will display ‘My account’ and take them directly to their account.


7) Display a checkout link in a template file

This snippet displays a link to your checkout when there are products in the cart. If you want to display the checkout link regardless, remove the if statement

8) Change number of products displayed per page

If you want to display 25 product per page you should add this code to your functions.php. You can also alter that number to your preference.

9) Set Image Dimension

Add the following snippet to your themes functions.php file to adjust the quantity inputs behavior.

Set the starting value, maximum value, minimum value and increment amount

10) Automatically Complete Orders

Sometimes I like it when the cart automatically completes the orders. To achieve this auto completion I use the following block of code

11) Change email subject lines

Default Woocommerce email subject line are not the best, you can customize theme using the following code:

12 ) Adjust the quantity input values

Add the following snippet to your themes functions.php file to adjust the quantity inputs behavior. Set the starting value, maximum value, minimum value and increment amount.

13) Allow shortcodes in product excerpts

Shorcodes in WordPress make it very easy for you to publish content without editing theme core files. To allow shortcodes in product excerpts, I use the following code.

14) Change add to the cart button text

Customizing cart button allows you to display text in your preferred text. You can add the following to your functions.php file to change add to the cart button text.

15) Products loop

This is the most important snippet I use regularly to display the products. The product loop is very useful when you are creating page template to show case products. Here is the products loop.

16) Remove the breadcrumbs

Occasionally, you want to remove the breadcrumbs, here is the quick snippet to help you remove woocommerce breadcrumbs from your pages.

17) Replace shop page title

Using this block of code you can quickly, replace the title of your shop. Just substitute the return value with your preferred name.

18) Order by price, date or title on shop page

Ordering product by price, date and title is a good way to help customers sort out the products in your site. The following snippet helps you to order the products by price, date or the title.

19) Redirect to the checkout page after adding to cart

To improve the sales conversions, automatically redirecting to the checkout page after adding the product to cart is a cool move. To auto-redirect customers to checkout when they add products to cart, use the following code:

20) Remove product categories from the shop page

If you want to get rid of a certain product category from your shop page, this code is very useful. Maybe you don’t want to display a certain category of product on the shop since they are not the best sellers, use this snippet.


I have shared the most useful snippets I use in my day to day wooCommerce development, I hope this list helps you to quickly edit wooCommerce themes and woocommerce websites.

If you are new to wooCommerce development, these snippets should help you get started with wooCommerce development as well as make a good reference for you in the future.I would like to get feedback from you. If you have additional comments, compliments or want to share your wooCommerce snippets with us, please feel free to leave us a comment.

Pin It on Pinterest

Share This