WooCommerce: Disable Payment Method If Product Category @ Cart

Today we take a look at the WooCommerce Checkout and specifically at how to disable a payment gateway (e.g. PayPal) if a specific product category is in the Cart.

There are two tasks to code in this case: (1) based on all the products in the Cart, calculate the list of product categories in the Cart and (2) disable a specific payment ID if the target product category is in the Cart.

May sound difficult but don’t worry – solution is right below. Enjoy!

Continue reading WooCommerce: Disable Payment Method If Product Category @ Cart

WooCommerce: Disable Payment Gateway For Specific Shipping Method

Today we take a look at the WooCommerce Checkout Page and specifically at how to disable a payment gateway (for example PayPal) when a specific shipping method is selected (e.g. “local_pickup”).

Specifically, you will learn how to “get” the selected shipping method on the go (thanks to “sessions”), and also how to “unset” a payment gateway. Enjoy!

Continue reading WooCommerce: Disable Payment Gateway For Specific Shipping Method

WooCommerce: Exclude Category from ‘products’ Shortcode

The WooCommerce [products] shortcode displays all products in your shop. There is even an attribute called “category” where you can specify comma-separated list of category slugs in order to further filter the output.

What you can’t do is define a list of unwanted categories (think of “uncategorized” for example) i.e. a list of categories you want to exclude from the products shortcode output.

So, here’s the fix, enjoy!

Continue reading WooCommerce: Exclude Category from ‘products’ Shortcode

WooCommerce: Add Product to Cart On Visit Programmatically

Quite an interesting functionality! A WooCommerce client wanted their Cart pre-filled with one product as soon as their customers accessed the website. I don’t remember the exact reason, but this could be useful when you want to give them a free product by default, or you want to send your visitors straight to checkout with a product already in the cart without letting them add anything first.

Adding an item to cart programmatically is the same as “automatically”. Basically, all users will have a default, non-empty Cart filled with an item of your choice. So, let’s see how this snippet works!

Continue reading WooCommerce: Add Product to Cart On Visit Programmatically

WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages

I’ve created a visual HTML hook guide for the WooCommerce Archive Page (which is the same page for the Shop, Category, Tag pages). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can also copy/paste). If you like this guide and it is helpful to you, let me know in the comments!

Thanks to this WooCommerce Archive Visual Hooks Guide, you can now go to your template’s functions.php file and use “add_action(‘place-hook-here’,’your-PHP-function-here’);” – you can then place your custom functions exactly where you like them to be. Enjoy!

Continue reading WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages

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