Limit Which Products Can Use the WooCommerce USPS Shipping Gateway

Recently a member of the Advanced WooCommerce Facebook Group asked:

“I wanted to see if it were possible to limit which products can use the Woo USPS plugin shipping…”

There is almost always an option to purchase an extension from that offers the needed functionality. In this case that extension would be WooCommerce Conditional Shipping and Payments. The benefit of using an extension like this is, it will be maintained for you by the author of the plugin.

In some cases a premium plugin offers way more code than needed and it may be worth a custom solution. I have written a quick set of functions that achieve the OP’s request:


Add this code snippets can be added to your theme / child-theme’s functions.php file.

Before adding the snippets, make sure you clear your WooCommerce cache ( WooCommerce → System Status → Tools → WC Transients → Clear transients ), as shipping methods are cached.

A New Way to Learn (the start of a series)


In the early summer of 2011 I had high hopes of becoming a famous blogger, though I did not know enough to use the term “blogger” yet. My subject was going to be raw milk and other alternative ideas of nutrition, medicine and exercise. If I was going to write for a website I would need a website. I secured the domain, I was so clever. Now I needed the website.

I asked my brother if he could refer a web developer. I considered my brother to be an expert. This had something to do with the fact that he had started developing websites 10 years prior at the ripe age of 12. He had moved on to the computer science department of UMASS Amherst so I was sure he was much too busy. When I asked Evan, he kindly replied “you can do it”. He had recently turned 21 so I thought “maybe he is drunk”. I tried him another few times but his answer never changed. I thought to myself, “What does Evan know that I don’t? Duh, how to build websites”.

One end of summer day I was sitting in a local coffee shop. This particular coffee shop had a “Leave a book, take a book” shelf. I glanced over and noticed an HTML5 for Dummies bright yellow book on the shelf. I could remeber that was an acronym Evan had mentioned several times when talking about website development. I humbled myself and adopted the free book as my own.

HTML5 for Dummies bookLater on that evening I sat at my 17″ mid 2010 Macbook Pro and started reading the first few pages of the book. I was instructed to create a text document (I did this is TextEdit), give it the extension .html save and open it in the browser (Safari at the time). What happened next changed my life for ever. The next step was to type the following in the text document, save and then refresh the browser:

<h1>Hello World!</h1>

WHOA!!!!! I am not completely sure why this impressed me so much. My heart sped up, my eyes grew large, and I needed MORE!

You may be wondering “What did he do next?”, It would not be crazy to think I blew through that book in less than a week. The truth is I never looked at that book again. What happened next was I started Googling. “How to make a webpage red”, “How to change the text on a webpage”, “How to include an image on my website”, “How to make a horizontal menu bar”, and on and on and on… At this stage Googling was slow. I hardly knew what HTML meant how could I Google the correct terms. However, I found answers and slowly fed my new desire.

This was the start of my learning how to build websites. I have continued to use this method (Googling) until today. I write most of my CSS and HTML from memory. This includes CSS3 and HTML5. Some examples are pseudo selectors like :nth-child() and properties like transform. More examples are HTML5 semantic elements like <header>, <nav>, <article>, etc… I have a firm hold on OOP (Object Oriented Programming) with PHP (PHP Hypertext Processor) and maximizing my front end development with Javascript. I have even written a few MySQL queries. I have leveraged the command line tool for server management and getting the most out of my Mac. I now also enjoy the security of revision control powered by git. I use the CSS preprocessor SASS particularly in the newer scss syntax. The list goes on and now I just sound like I am bragging.

The important part is, I am 100% self employed and able to support my family and I. Stay tuned and you will meet some of them as well.

The point of all this is to demonstrate the jump from summer of 2011 to now. I attended no school, I took no online courses (watched half of a video and spent a couple hours on code academy.), there was no developer bootcamps involved, I didn’t have any friends or relatives available to bounce questions off of (I told you my brother was busy. You won’t believe what he is doing now). I am a student of the search engine. Google is my professor.

In this day and age almost every person in the United States has access to the internet. Those of us that do can find the answer to ANYTHING. For the generation who has always had the internet they may take it for granted. For the generations who always got by without the internet, they might be deterred or not realize the power. Then there is my generation. I was primed and thirsty for information. Yet I had enjoyed enough conveniences that I was too lazy to go to the library. The internet was perfect. If I knew there was a connection near by I would find the computer, sit at at and try to think of something to search. I wanted to use it just because it was there. Then an internet connection was added to the phone in my pocket, BOOM!

In the series to come I will cover what happened between 2011 and now. I will share my trials and tribulations. I will document the best way to search for things without knowing their name. Maybe the “University of the Search” is not for everyone, but it was definitely for me. So bookmark, subscribe leave me open in another tab forever like I do. While you wait, go and Google “How to Google”.