Question

I know how to get the customer's default shipping address information, but how can I get a "one-time" shipping address before the order is submitted?

Example

Customer from Georgia has default addresses in Georgia, but is shipping to Florida for this new order. If I want to know what their shipping address is for this case, how can I find out?

I need to this information for Tax Calculation purposes, so I can charge tax if the shipment is going to Florida. Is this even possible?

edit

Based on R.S.'s suggestion, I'm trying to get an observer set up but it isn't working as I expected. Here is what I have currently:

Config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mbs_Tax>
            <version>0.1</version>
        </Mbs_Tax>
    </modules>

    <global>
        <events>
            <sales_quote_collect_totals_before>
                <observers>
                    <tax>
                        <type>singleton</type>
                        <class>Mbs_Tax_Model_Observer</class>
                        <method>salesQuoteCollectTotalsBefore</method>
                    </tax>
                </observers>
            </sales_quote_collect_totals_before>
        </events>
    </global>
</config>

Observer.php

class Mbs_Tax_Model_Observer {
    public function salesQuoteCollectTotalsBefore($observer) {
        $quote = $observer->getQuote();
        $address = $quote->getShippingAddress();
        $region = $address->getData('region');
        Mage::log("Address from salesQuoteCollectTotalsBefore: region ".$region,null,"tax.log");
        if(strtoupper($region)==="FLORIDA") {

            Mage::log("Shipping to Florida: ".print_r($quote->getShippingAddress()->getData('tax_amount'), true),null,"tax.log");
        }
    }
}
Was it helpful?

Solution

Try creating an observer for <sales_quote_collect_totals_before>

Then in your observer

$quote = $observer->getQuote();
$address = $quote->getShippingAddress()
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top