Magento的:获取所有运费(Magento : Get all Shipping Rates)

2019-09-21 04:14发布

我怎样才能用在Magento的运费数组/对象,如统一收费,免费送货等?

无关选择的地址或产品。

Answer 1:

这里的另一种方式。 您需要设置一个zip和国家 - 即使不为你的送货方式无所谓。

// Change to your postcode / country.
$zipcode = '2000';
$country = 'AU';

// Update the cart's quote.
$cart = Mage::getSingleton('checkout/cart');
$address = $cart->getQuote()->getShippingAddress();
$address->setCountryId($country)
        ->setPostcode($zipcode)
        ->setCollectShippingrates(true);
$cart->save();

// Find if our shipping has been included.
$rates = $address->collectShippingRates()
                 ->getGroupedAllShippingRates();

foreach ($rates as $carrier) {
    foreach ($carrier as $rate) {
        print_r($rate->getData());
    }
}


Answer 2:

你不能这样做“风马牛不相及”,因为你需要地址的数据(账单或送货,如果只开票,然后传送设置相同的账单:国家,邮政编码,区域相关的送货方式)进行设置和报价至少有一个简单项目(报价现有的,虚拟的和可下载的产品不需要运费)。 之后,你可以你的报价对象调用

$quote->getShippingAddress()->getGroupedAllShippingRates();


Answer 3:

我想到了...

 $carriers = Mage::getStoreConfig('carriers', Mage::app()->getStore()->getId());
foreach ($carriers as $carrierCode => $carrierConfig) {
print_R($carrierConfig);
}

谢谢您的帮助



文章来源: Magento : Get all Shipping Rates
标签: magento