Woocommerce Code Snippet – Top 10 Most Used Basic Customization Snippet for Beginner

This post list top 10 most used WooCommerce code snippet for beginners. All the snippet will go to functions.php file of your child theme folder.

Note: This snippets are tested with WooCommerce version 2.6.4 and this required basic understanding of actions & filters hooks along with good understanding of PHP language. You can read basics of actions & filter here.

1 .Remove/Hide WooCommerce Product Sorting Dropdown from Shop and Category pages

At times it doesn’t makes sense to keep product sorting dropdown on your shop and category pages. We can remove it altogether from displaying or simply hide it from the page. To remove product sorting option use below code snippet. Simply add it to your child theme’s function.php file.

To hide product sorting option from the page, add below style code into your child theme’s style.css file

2 .WooCommerce Rename Single Product page Tabs

Put below code snippet in your child theme’s functions.php file. Change tab’s title to suit your need.

3 .WooCommerce Remove Specific Product Tab on Single Product Page

If you want to hide specific tab on WooCommerce single product page, you can use below snippet. Put them in the theme’s functions.php file

4 .Reorder Tabs on WooCommerce Single Product page

Paste below snippet in the functions.php file within your child theme folder:

5 .Change Add to Cart Button Text for particular WooCommerce product type

Each store sells different product and based on your product type you would like to change the “Add to Cart” button text on either Shop page or Single Product page. Here I will guide you, how you can do that for each of the default product type provided by WooCommerce. Be it a Simple product, Variable Product, Grouped product or External product.


In order to achieve this add this snippet to the functions.php file of your child theme.

This code will change button text on Shop and Category Pages. Please note below code snippet doesn’t change external product “Add to Cart” button text. To change External Product button text, use code snippet given further on this tutorial.

Use this snippet to change “Add to Cart” Button text on Single Product Page. Please note for external product we can not have separate button text for Shop/Category pages or Single product page. They both will be same.

6 .WooCommerce Hide or Disable Coupons

At times specially after festive season you may want to temporary hide or disable coupons. There are two ways to do this.

Method 1: You can disable coupon from WooCommerce settings Page.
Uncheck “Enable the use of coupons” checkbox as given in below screenshot.


WooCommerce Coupon Settings

Method 2: You can do this by adding below code block to functions.php file in your child theme folder.

7 .WooCommerce Display Coupon on Checkout page only

There are times when you would like to display coupon field only on Checkout page. Below snippet will hide coupon fields on Cart page and display it only on Checkout page. Copy and paste this snippet to functions.php file

8 .WooCommerce Change Default Placeholder image of Product Page

Add below code to functions.php of your child theme folder.

Note: To change placeholder image, upload your image to WordPress media library. Get the image ID of the uploaded image as suggested in below image.

WordPress Media Image ID

then replace 2966 from the below code with attachment ID of the image you have uploaded.

9 .WooCommerce Charge additional amount if Cart Quantity exceed given amount

This snippet will charge additional handling fees if total no. of products in cart exceeds to 10. You can change Qty “10” to suits your application. Simply put this code to your child theme’s functions.php.


This will add additional charges row to Cart Totals Table as given in the below screenshot when Total no. of products in cart exceeds 10.

WooCommerce Cart - Additional Fees

10 .WooCommerce Customize Checkout Address and Comments fields

WooCommerce provides very useful filter that helps to customize checkout fields. You can use it to Edit, Remove, Modify or Remove Billing Address. Below is a function that fits almost all Checkout fields customisation requirement

Leave a Reply

Your email address will not be published.