1

We are using Magento Enterprise 1.12.0.2, and I am trying to enable both Ground and Home Delivery at the same time so that customers can choose the option that suits their needs to the best. Right now I can only get one to work...I can't get both to appear at the same time. Any way to fix this?

1

I had the same issue and spoke to FedEx. Only one can be enabled, not both. The options rely on whether or not you have the residential delivery set to yes or no. Setting it to no will allow ground but not home delivery. The opposite is true if you set it to yes. FedEx recommended setting it to yes and allowing home delivery for my client, which is a clothing retailer.

1

Actually this can be done. Unfortunately Magento does not do it.

What other platforms do is perform an address check on the Recipient address. If it is Commercial , it sets the flag to false when it asks for rates. If it is Residential it sets the flag to true.

I am really surprised that Magento lacks this capability. In Magento it is a static flag that you set in the extension configuration. So you have the choice of setting it to Residential and over charging all your Ground-Commercial customers or setting it to Commercial and undercharging all your Residential customers.

1

Magento doesn't provide this option per default. You need a custom solution - something like this (not fully tested):

  1. On checkout you need to determine if its a residential or a business address. You probably want to add some kind of checkbox at the shipping address step.
  2. Then you'll catch the value of the checkbox via observer and based on this value you'll change the Fedex config and API request on the fly

An extension could look like this:

Rewrite Mage_Usa_Model_Shipping_Carrier_Fedex

or copy

app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php

to

app/code/local/Mage/Usa/Model/Shipping/Carrier/Fedex.php

Add/Modify 2 lines in function _formRateRequest($purpose)

protected function _formRateRequest($purpose)
    {
        // ++++++++++ NEW ++++++++++
        $residential = (Mage::getSingleton('core/session')->getResidenceDelivery() == 2) ? 0 : (bool)$this->getConfigData('residence_delivery');

        $r = $this->_rawRequest;
        $ratesRequest = array(
            'WebAuthenticationDetail' => array(
                'UserCredential' => array(
                    'Key'      => $r->getKey(),
                    'Password' => $r->getPassword()
                )
            ),
            'ClientDetail' => array(
                'AccountNumber' => $r->getAccount(),
                'MeterNumber'   => $r->getMeterNumber()
            ),
            'Version' => $this->getVersionInfo(),
            'RequestedShipment' => array(
                'DropoffType'   => $r->getDropoffType(),
                'ShipTimestamp' => date('c'),
                'PackagingType' => $r->getPackaging(),
                'TotalInsuredValue' => array(
                    'Amount'  => '0.00',
                    'Currency' => $this->getCurrencyCode()
                ),
                'Shipper' => array(
                    'Address' => array(
                        'PostalCode'  => $r->getOrigPostal(),
                        'CountryCode' => $r->getOrigCountry()
                    )
                ),
                'Recipient' => array(
                    'Address' => array(
                        'PostalCode'  => $r->getDestPostal(),
                        'CountryCode' => $r->getDestCountry(),
                        'Residential' => $residential // ++++++++++ NEW ++++++++++
                    )
                ),

                ....

The observer in app/code/local/MyModule/FedexGround/Model/Observer.php should look something like this

class MyModule_FedexGround_Model_Observer
{
    public function checkIsBusinessAddress($observer)
    {
        $data = Mage::app()->getRequest()->getParams();
        if (isset($data['billing']['is_residential_address'])) {

            $isResidential = ($data['billing']['is_residential_address'] == 1) ? 1 : 2;
            Mage::app()->getStore()->setConfig('carriers/fedex/residence_delivery', $isResidential);
            Mage::getSingleton('core/session')->setResidenceDelivery($isResidential);
        }
    }
}

You can use the sales_quote_address_save_after event, so your config.xml will look like

<?xml version="1.0"?>
<config>
    <modules>
        <MyModule_FedexGround>
            <version>0.1.0</version>
        </MyModule_FedexGround>
    </modules>
    <frontend>
        <layout>
            <updates>
                <fedexground>
                    <file>mymodule/fedexground.xml</file>
                </fedexground>
            </updates>
        </layout>
    </frontend>
    <global>
        <models>
            <mymodule_fedexground>
                <class>MyModule_FedexGround_Model</class>
            </mymodule_fedexground>
        </models>
        <events>
            <sales_quote_address_save_after>
                <observers>
                    <mymodule_fedexground>
                        <type>singleton</type>
                        <class>MyModule_FedexGround_Model_Observer</class>
                        <method>checkIsBusinessAddress</method>
                    </mymodule_fedexground>
                </observers>
            </sales_quote_address_save_after>
        </events>
    </global>
</config>

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.