Magento Forum

Unset a shipping method
 
KThompkins
Sr. Member
 
Total Posts:  150
Joined:  2011-09-01
 

Is there a way I can unset a shipping method?  I have two types of products, one uses a custom table rate module for the shipping prices, the other gets it from UPS. I have the UPS price being added to the table rates, but then I want to remove the UPS from the list of shipping rates ONLY if the table rate exists. I need to do this in the module, not in the onepage checkout. I don’t see anything in the code that’s the opposite of $result->append().

Here’s some of my custom table rate module

public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    
{
        
if(!$this->getConfigFlag('active')){
            
return false;
        
}

        $shipping 
Mage::getModel('shipping/shipping');
        
$upsRates $shipping->getCarrierByCode('ups');
        if(
$upsRates){
            $upsResult 
$upsRates->collectRates($request);
            if(
$upsResult){
                
foreach ($upsResult->getAllRates() as $method{
                    Mage
::log("UPS rate is ".$method->getPrice());
                    
$upsPrice $method->getPrice();
                
}            
            }
        }
        
        $result 
Mage::getModel('shipping/rate_result');
        
$chkoutSess Mage::getSingleton('checkout/session');
        
$chkoutSess->setILHandling(0);
        
// module-specific code here

        
$rates $this->getRates($request$_categories);

        if (!empty(
$rates))
        
{
            Mage
::log(count($result));
            
$result->reset();
            
Mage::log(count($result));

            
// This is where I'm trying to unset the UPS shipping method

            // more module-specific handling

        
}
        
else
            return 
false;

        return 
$result;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top