1

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");
        }
    }
}
1

Try creating an observer for <sales_quote_collect_totals_before>

Then in your observer

$quote = $observer->getQuote();
$address = $quote->getShippingAddress()
  • I set up an observer to simply write to tax.log (to ensure it's working first) but I either have it set up incorrectly or it's not firing where I think it is. I expect it would run after I add products to the order, before submitting the order. Is this correct? – travisw Jun 25 '15 at 17:10
  • Not setup correctly ... take a look at stackoverflow.com/a/16423413/1191288 – Renon Stewart Jun 25 '15 at 17:16
  • How do I save the data I'm changing (tax_amount)? – travisw Jun 25 '15 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.