我知道如何获取客户的默认送货地址信息,但我如何在提交订单之前获得“一次性”送货地址?

示例

来自乔治亚州的客户在格鲁吉亚有默认地址,但为此新订单运送到佛罗里达州。如果我想知道他们的送货地址是在这种情况下,我怎样才能找到?

我需要这些信息进行税收计算目的,因此如果货物将到佛罗里达州,我可以收取税。这是可能的吗?

编辑

基于R.S.的建议,我试图让观察者设置出来,但它不起作用,因为我预期的。这是我目前的:

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>
.

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

有帮助吗?

解决方案

尝试为世代odicetagcode创建观察者

然后在观察者中

$quote = $observer->getQuote();
$address = $quote->getShippingAddress()
.

许可以下: CC-BY-SA归因
scroll top