PHP Code to list All WooCommerce Products From a specific category

WooCommerce is no doubt one of the best plugin which gives you full flexibility to customize it in whatever you wish it.

It has tons of filter and action hooks giving you control to customize it as per your application need. But at times you may need to go one level deeper than using these hooks. This point of time you would love to get your hand dirty and go for PHP code which gives you super freedom to customize WooCommerce plugins at much finer level.

Continue reading →

PHP Code to List All WooCommerce Categories

By Default WooCommerce doesn’t list Categories on Shop. You may need to tweak your shop page to display Categories as well instead of listing just products.

Below PHP Code will help you to exactly do that. It will display list of categories with permalink for each category page. It is a basic snippet to get WooCommerce Category list which you can use for any cusotmization purpose on any page. Feel free to tweak it to suit your need.

Continue reading →

WooCommerce – Display Price and Add to Cart button for specific user role only on Shop and Single Product pages

There are times when you want to display your products as catalog only and allow visitors to buy products only when they are logged in (after registration).

In such case you want to display products with basic information like an image, short description, SKU etc. without displaying product price and giving ability to purchase the items.

This tutorial provides you the code snippet to exactly do that. Below snippet that goes to functions.php file of your child theme, will display “Add to Cart” button and “Price” on Single Product page as well as on Shop and Category pages, only if user role is either Admin OR Customer. Feel free to experiment with the code by changing the user role that suits your application.
Continue reading →