1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fedex Integration

Discussion in 'PHP' started by jeet_0077, Jun 15, 2007.

  1. jeet_0077

    jeet_0077 New Member

    Joined:
    Jun 15, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I am trying to generate a online shipping calculator and that I doing by connecting with the FedEx. For the same purpose I have down loaded some code from phpclasses.org.

    But I am facing some problem in integrating the same in my project.



    I have to provide the calculation for both domestic and International with the following options-

    For Us Domestic I have to provide- 1) FedEx Ground 2) FedEx 2 day express 3) FedEx Overnight Express.



    And for International – 1) International Priority Express

    2) International Economy.



    To get the different tag fields I have down loaded APIDirectTaggedTransactionGuideJan2007.pdf from the FedEx website.

    Code:
    
    include('fedexdc.php');
    
     
    
    if ($_POST['uSubmit']!=""){
    
                // create new fedex object
    
                $fed = new FedExDC('342464483','0');// I have not yet get the meter number
    
                $sType = $_POST['sType'];
    
                $ship_data = array(
    
                             75=>   'LBS'
    
                            ,16=>   'Ma'
    
                            ,13=>   '44 Main street'
    
                            ,5=>    '312 stuart st'
    
                            ,1273=> '01'
    
                            ,1274=> '01'
    
                            ,18=>   '6173335555'
    
                            ,15=>   'Boston'
    
                            ,23=>   '1'
    
                            ,9=>    '02134'
    
                            ,183=>  '6175556985'
    
                            ,8=>    'MA'
    
                            ,117=>  'US'
    
                            ,17=>   '02116'
    
                            ,50=>   'US'
    
                            ,4=>    'Vermonster LLC'
    
                            ,7=>    'Boston'
    
                            ,1369=> '1'
    
                            ,12=>   'Jay Powers'
    
                            ,1333=> '1'
    
                            ,1401=> '1.0'
    
                            ,116 => 1
    
                            ,68 =>  'USD'
    
                            ,1368 => 1
    
                            ,1369 => 1
    
                            ,1370 => 5
    
                            ,3025 => $sType // This I have added
    
                );
    
                
    
                // Ship example
    
                $ship_Ret = $fed->ship_express($ship_data);
    
                
    
                if ($error = $fed->getError()) {
    
                            echo "ERROR :". $error;
    
                } else {
    
                            // Save the label to disk
    
                            $fed->label('mylabel.png');
    
                
    
                }
    
    }
    
     
    
    /* tracking example
    
     
    
    $track_Ret = $fed->track(
    
    array(
    
        29 => 790344664540,
    
    ));
    
     
    
    */
    
     
    
     
    
     
    
    echo $fed->debug_str. "\n<BR>";
    
    echo "Price ".$ship_Ret[1419];
    
     
    
     
    
    ?>
    
    <table>
    
    <form method="post" action="">
    
    <tr>
    
    <td>US Customers :</td>
    
    <td>&nbsp;&nbsp;</td>
    
    <td><input type="radio" name="sType" value="FDXG">&nbsp;&nbsp;Fedex Ground</td>
    
    </tr>
    
    <tr>
    
    <td>&nbsp;&nbsp;</td>
    
    <td>&nbsp;&nbsp;</td>
    
    <td><input type="radio" name="sType" value="">&nbsp;&nbsp;Fedex 2 Day Express</td>
    
    </tr>
    
    <tr>
    
    <td>&nbsp;&nbsp;</td>
    
    <td>&nbsp;&nbsp;</td>
    
    <td><input type="radio" name="sType" value="FDXE">&nbsp;&nbsp;Fedex Overnight Express</td>
    
    </tr>
    
    <tr>
    
    <td>International Customers :</td>
    
    <td>&nbsp;&nbsp;</td>
    
    <td><input type="radio" name="sType" value="">&nbsp;&nbsp;International Priority Express</td>
    
    </tr>
    
    <tr>
    
    <td>&nbsp;&nbsp;</td>
    
    <td>&nbsp;&nbsp;</td>
    
    <td><input type="radio" name="sType" value="">&nbsp;&nbsp;International Economy</td>
    
    </tr>
    
     
    
    <tr>
    
    <td>
    
    <input type="submit" name="uSubmit" value="Calculate">
    
    </td>
    
    </tr> FDXE/FDXG
    
    </form>
    
    </table>
    
    Here in the above code I have given radio button values FDXG and FDXE for FedEx ground and over night express. I am not able to understand what value I shall pass for the other radio buttons. From the PDF documentation I do not really understand what value I shall use for tag field 3025 for all the above options.

    Can some one please help me out in this?


    Thanking you

    Abhik
     
    Last edited by a moderator: Jun 15, 2007

Share This Page