WooCommerce Visual Hook Guide: Single Product Page

Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can copy/paste). If you like this guide and it’s helpful to you, let me know in the comments!

Now that you know the product page hooks, you can override the WooCommerce Single Product Page via your child theme’s functions. You can remove default elements (for example, the featured image, the add to cart form, related products…), you can add your custom elements by picking the correct positioned “hook” and triggering your function, and you can even “move” existing elements. Need a video tutorial? Watch it now →

Continue reading WooCommerce Visual Hook Guide: Single Product Page

WooCommerce: Remove or Rename SALE! Badge

Here’s yet another easy WooCommerce PHP snippet if you wish to completely remove / hide or translate / rename the SALE! badge on the homepage, shop page, category pages and single product pages.

Once again, with a few lines of code (and specifically, the “woocommerce_sale_flash” filter) you can achieve anything you want. Enjoy!

Continue reading WooCommerce: Remove or Rename SALE! Badge

WooCommerce: Translate “You may also like…” Text

Apparently, since WooCommerce 4.1, there is now an easy way to edit the “You may also like…” WooCommerce string thanks to a brand new “PHP filter”. Kudos to Damien Carbery for reporting this new method.

So, as usual, simply copy/paste the snippet below in your child theme’s functions.php and it will do what it says on the tin. Enjoy!

Continue reading WooCommerce: Translate “You may also like…” Text

WooCommerce: Remove a Tab @ Single Product Page

There are ways to completely remove the WooCommerce Single Product page tabs, but in case you wish to remove only one of them, these easy snippets will teach you how to do just that.

For example, you may want to hide the “Reviews tab because you don’t want to enable product feedback. Or maybe you would like to hide the “Additional Information” tab, because you don’t need that information to be seen.

Either way, it’s super easy – enjoy!

Continue reading WooCommerce: Remove a Tab @ Single Product Page

WooCommerce: is_single() Doesn’t Work [Solved]

When building custom functions and using hooks and filters, you may want to apply those changes to a unique product id: “If product id = xxx, then execute this function”.

Honestly, I tried to do that with the simplest of all solutions (is_single WordPress conditional tag) but it didn’t work for me. Hopefully, I can help you solve this in 2 seconds!

Continue reading WooCommerce: is_single() Doesn’t Work [Solved]

WooCommerce: Fixing Fatal error Call to undefined function wc_get_order()

I developed a custom payment gateway plugin for a client, who wanted to add a similar method to “cod” (cash on delivery). FYI, he wanted to add a method called “card on delivery”. I simply duplicated the code, added the PHP to a file, made a plugin and gave him the plugin zip file. And everything was working great… until he did a test checkout. Continue reading WooCommerce: Fixing Fatal error Call to undefined function wc_get_order()

WooCommerce: Move Social Sharing @ Single Product Page

JetPack sharing (and other social media sharing plugins) allow you to add social media sharing to your woocommerce products. However, the sharing buttons will only show at the bottom of the “Long description”.

How to move that up a bit, say between the short description and the product tabs? Simply add this function to your functions.php file editor: Continue reading WooCommerce: Move Social Sharing @ Single Product Page

WooCommerce: Remove Additional Information Tab @ Single Product

The “Additional Information” tab on the single product page is somewhat annoying and, honestly, quite useless.

There are 2 simple methods to “hide” it or delete it completely: a CSS and a PHP solution. In the first case, you can input the code in your style.css; in the second case use your child theme’s functions.php.

However, Always remember that PHP is better than CSS: with CSS you load the element and then hide it, while with PHP you stop the element from loading. Clearly, PHP is a better way to do it!

Continue reading WooCommerce: Remove Additional Information Tab @ Single Product

WooCommerce: Show Number Of Products Sold @ Product Page

WooCommerce database already stores the number of products sold for you.

Therefore, you may want to show such number on the product page, close to the Add To Cart button. As we’ve seen in my book Ecommerce and Beyond, showing the number of sales for each product can increase your sales conversion rate.

All you need is pasting the following code in your functions.php. Enjoy!

Continue reading WooCommerce: Show Number Of Products Sold @ Product Page

WooCommerce: Hide Price & Add to Cart for Logged Out Users

You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out.

All you need is pasting the following code in your functions.php (please note: your theme may have overwritten some default WooCommerce functions, hence the code below may not work. Contact me if you need custom code). Enjoy!

Continue reading WooCommerce: Hide Price & Add to Cart for Logged Out Users

WooCommerce: Disable Variable Product Price Range $$$-$$$

You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case).

With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price – variable products with a single price (i.e. all variations have the same price) will keep their original format.

Simply paste the following code in your child theme’s functions.php and enjoy!

Continue reading WooCommerce: Disable Variable Product Price Range $$$-$$$