So we are running Magento CE 1.9.0.1 and are mid-way through developing a custom shipping module as we have largely different shipping costs than the traditional shipping can cover. We are also using a OneStepCheckout plugin for the checkout process.
OneStepCheckout plugin: http://www.mage-world.com/magento-one-step-checkout-extension.html
Custom shipping module: http://www.smashingmagazine.com/2014/01/create-custom-shipping-methods-magento/
We need to be able to detect the state that the user (customer) is shipping to as we need to charge extra for shipping to Hawaii, Alaska and Puerto Rico. We also have some additional logic in the shipping module that detects $100 and day of the week, all of which work well.
So in the shipping module:
/app/code/local/CustomShipping/MyCarrier/Model/Carrier.php
We access the cart total like this:
$cartTotal = Mage::getSingleton('checkout/session')->getQuote()->getGrandTotal();
However no "state / region" element exists in that part (obviously).
We have the OneStepCheckout (OSC) refresh the shipping change on address selection (ajax) which to me should signify that there is an object somewhere in the magento stack that contains the updated address info including the state that I can use in the module to refresh the shipping options, I just can't find it.
We are aware that on the initial load, the shipping options will be the "default" ones and that they need to update once they select their shipping state.
Help? Can someone help me find where to get the state/region from the checkout/cart object?