WooCommerce Add a product to the cart programmatically

At times you may want to give free gift when customer purchase specific product from your shop. Instead of user need to select the gift explicitly you would like to add it automatically to the cart, when user add given product to the cart.

Below code snippet will help you to achieve exactly that. In this PHP code you can select which product to add to the cart and quantity of that product as well.

Continue reading →

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 →