Magento:获取所有运费

Boq*_*Boq 3 magento

如何获得具有magento运费的数组/对象,如统一费率,免费送货等?

与所选地址或产品无关.

小智 13

这是另一种方式.您需要设置一个拉链和国家/地区 - 即使这与您的运输方式无关.

// 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());
    }
}
Run Code Online (Sandbox Code Playgroud)