I want to disable USPS on the frontend if a product's length is over 12" (the max size USPS box we use).
I understand there is an extension, Amasty Shipping Restrictions that gets high praise, but this is much more complex than I require.
Is there a straightforward way to program this into my checkout rules?
Best Answer
Solution Logic
I set up a solution that iterates through each item in a customer's cart, check's each item's height attribute, then if any item is over a given length, it raises the flag(s) for whatever shipping method can't ship something that length, and hides the shipping method(s) from the customer's view.
I configured this solution to work for USPS (max length 12", limited by the largest box our store offers), UPS (max length 108" per UPS Ground website), and FedEx (max length 165" per FedEx website).
To reiterate, if any one item is over the maximum length, then that shipping method is disabled for the entire cart. I injected this logic check into the "View Cart" and "Onepage Checkout" pages to hide any unavailable shipping methods dynamically.
Files changed
/app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml
/app/design/frontend/rwd/default/template/checkout/cart/shipping.phtml
PHP added
Both Files
Shipping.phtml
Available.phtml