Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Adding additional fee for specific USPS shipping method
 
kdask
Jr. Member
 
Total Posts:  1
Joined:  2009-03-25
 

Hi,

Is there any way to add an additional cost for a specific USPS shipping method?
For example i want to add an extra 0.19 cents to the usps price quote i’m getting from the api
but only for the Media Mail option.

Maybe someone can point me the file/function where the get price quote occurs so to try to add it manually?

Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
DustinEMiller
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2011-09-14
 

One way you could do it is to look in app\\code\\core\\Mage\\USA\\Model\\Shipping\\Carrier\\USPS and look for this block of code in the _parseXMLResponse function:

$result Mage::getModel('shipping/rate_result');
        if (empty(
$priceArr)) {
            $error 
Mage::getModel('shipping/rate_result_error');
            
$error->setCarrier('usps');
            
$error->setCarrierTitle($this->getConfigData('title'));
            
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
            
$result->append($error);
        
else {
            
foreach ($priceArr as $method=>$price{
                $rate 
Mage::getModel('shipping/rate_result_method');
                
$rate->setCarrier('usps');
                
$rate->setCarrierTitle($this->getConfigData('title'));
                
$rate->setMethod($method);
                
$rate->setMethodTitle($method);
                
$rate->setCost($costArr[$method]);
                
$rate->setPrice($price);
                
$result->append($rate);
            
}
        }

You probably want to apply the fee earlier in the code for a couple of different reason which I’ll let you figure out. This block is easier to point out, however.

What I would recommend doing is to first put your code changes in a new module. Then, add a new text field to the USPS section in the back end that will allow you to control the fee you would like to apply to whatever you method you want to apply it to. This way it isn’t hard coded.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top