WooCommerce is a very versatile platform for e-commerce that can be adjusted to cover almost any situation. For example, one of the requirements of our client Voorn Croquettes and Jacksonville Dutch Croquettes was that shipping could not take more than three days delivery, because their product is fresh without preservatives. The solution was to make a list of U.S. states where the UPS Ground delivery would take three or less days. The rest of the U.S.A would have to do with the much more expensive UPS 3 Day Select.
Many ecommerce sites opt to have many warnings to alert the potential client the type of shipping they have to choose, so their products arrive fresh. The problem is that if the client doesn’t pay attention, or makes a mistake, the company is not responsible. With decided to do it differently. It’s true that the customer is responsible for their shipment, we as the seller should minimize as much as possible the opportunities for these mistakes. This, in our opinion, is what differentiates a good ecommerce site to one that’s not.
WooThemes, creators of WooCommerce for WordPress, has an extension(WooCommerce Conditional Shipping and Payments) to condition shipment and payments in hundreds of ways, but when we needed this solution, it didn’t exist yet. However, WooCommerce has hundreds of filters and hooks from where we can modify it’s behaviour. So, we resolved the issue with the following code:
As can be seen here, we used the filter woocommerce_package_rates and modified the shipment options. An array contains the states to exclude. With a simple if-else statement we check the conditions and exclude as needed. This not only works for the official UPS extension, but also for the extension from Syn Media sold at Codecanyon.