Switch UPS Account Based on Shipping Class with UPS WooCommerce Shipping.
One of our customers, Scott, presented an interesting business case. He ships from two warehouses, located quite far from each other (one located on the East Coast of the US and the other in the West.) He maintains separate UPS accounts for each warehouse and wanted to use them selectively depending on which warehouse was closest to the customer.
Scott asked us if it is possible to connect more than one UPS accounts and choose which one to use for a particular order. In response, we devised a workaround for this case as described below:
When products belonging to shipping class ‘X’ are in the order, the plugin will select UPS Account number ‘A’ for label printing. When the products belonging to shipping class ‘Y’ are in the order, the plugin will select UPS Account number ‘B’. As you might be wondering, when products from both shipping classes (X and Y) are in the cart, the plugin will select UPS Account number ‘A’ again.
We developed a code snippet that enables to switch UPS accounts based on shipping class when using our UPS WooCommerce Shipping Plugin.
After updating your alternate UPS account number into the following code snippet, you can simply add the code snippet to your functions.php:
In the above code, there is an array
$alternate_account where you can configure the UPS account details (B) and a shipping class (Y) in the array.
If a particular order has only products belonging to this shipping class (Y), the alternative account (B) will be used, otherwise use default account (A).