Search code examples
magentofedex

Magento 1.8.1 - Remove FedEx Insurance


The default backend Magento 1.8.1 FedEx setting do not allow for the option of removing insurance and forces the default value of the item to be fully insured.

    'Version' => $this->getVersionInfo(),
        'RequestedShipment' => array(
            'DropoffType'   => $r->getDropoffType(),
            'ShipTimestamp' => date('c'),
            'PackagingType' => $r->getPackaging(),
            'TotalInsuredValue' => array(
                'Amount'  => $r->getValue(),
                'Currency' => $this->getCurrencyCode()

I am trying to get the 'Amount' to be set at $99 (all shipments get a default $100 coverage if damaged). Should I add the following line:

'Amount' => 99,

Please advise :)


Solution

  • I'm trying to remove the insurance value so my solution should be suitable as well for you.

    As pointed out by @Chris you should rewrite this file app/code/core/Mage/USA/Model/Shipping/Carrier/Fedex.php

    and change the method _formRateRequest

    How to Remove the insurance
    comment the code as shown below:

    ( line 330 )

     'RequestedShipment' => array(
                    'DropoffType'   => $r->getDropoffType(),
                    'ShipTimestamp' => date('c'),
                    'PackagingType' => $r->getPackaging(),
    //                'TotalInsuredValue' => array(
    //                    'Amount'  => $r->getValue(),
    //                    'Currency' => $this->getCurrencyCode()
    //                ),
                    'Shipper' => array(
                        'Address' => array(
                            'PostalCode'  => $r->getOrigPostal(),
                            'CountryCode' => $r->getOrigCountry()
                        )
                    ),
    

    AND ( line 380 )

           if ($purpose == self::RATE_REQUEST_GENERAL) {
    //            $ratesRequest['RequestedShipment']['RequestedPackageLineItems'][0]['InsuredValue'] = array(
    //                'Amount'  => $r->getValue(),
    //                'Currency' => $this->getCurrencyCode()
    //            );
            } 
    

    Change the amount
    if you want to use a fix value instead of commenting the line you should just set the 'Amount' to a fix value

    Suppose you want a fixed amount of 100$

    Change the code as shown below:

    Add this variable on the top of the method

    $amount = 100;
    

    ( line 330 )

     'RequestedShipment' => array(
                    'DropoffType'   => $r->getDropoffType(),
                    'ShipTimestamp' => date('c'),
                    'PackagingType' => $r->getPackaging(),
                    'TotalInsuredValue' => array(
                    'Amount'  => $amount),
                    'Currency' => $this->getCurrencyCode()
                    ),
                    'Shipper' => array(
                        'Address' => array(
                            'PostalCode'  => $r->getOrigPostal(),
                            'CountryCode' => $r->getOrigCountry()
                        )
                    ),
    

    AND ( line 380 )

           if ($purpose == self::RATE_REQUEST_GENERAL) {
               $ratesRequest['RequestedShipment']['RequestedPackageLineItems'][0]['InsuredValue'] = array(
                   'Amount'  => $amount,
                   'Currency' => $this->getCurrencyCode()
                );
            }