phpBMS

root/trunk/phpbms/modules/bms/shipping_estimate_ups.php

Revision 702, 4.9 KB (checked in by brieb, 2 years ago)

Updated copyrights to 2010

Line 
1<?php
2/*
3 $Rev: 145 $ | $LastChangedBy: mipalmer $
4 $LastChangedDate: 2006-10-21 18:27:44 -0600 (Sat, 21 Oct 2006) $
5 +-------------------------------------------------------------------------+
6 | Copyright (c) 2004 - 2010, Kreotek LLC                                  |
7 | All rights reserved.                                                    |
8 +-------------------------------------------------------------------------+
9 |                                                                         |
10 | Redistribution and use in source and binary forms, with or without      |
11 | modification, are permitted provided that the following conditions are  |
12 | met:                                                                    |
13 |                                                                         |
14 | - Redistributions of source code must retain the above copyright        |
15 |   notice, this list of conditions and the following disclaimer.         |
16 |                                                                         |
17 | - Redistributions in binary form must reproduce the above copyright     |
18 |   notice, this list of conditions and the following disclaimer in the   |
19 |   documentation and/or other materials provided with the distribution.  |
20 |                                                                         |
21 | - Neither the name of Kreotek LLC nor the names of its contributore may |
22 |   be used to endorse or promote products derived from this software     |
23 |   without specific prior written permission.                            |
24 |                                                                         |
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     |
26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       |
27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
36 |                                                                         |
37 +-------------------------------------------------------------------------+
38*/
39
40        session_cache_limiter('private');
41        require("../../include/session.php");
42        require("include/ups_price.php");
43
44        header('Content-Type: text/xml');
45        echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
46       
47        if(!isset($_GET["shipvia"]) || !isset($_GET["postalcodeto"])){
48        ?><response>
49        <value>0</value>
50</response><?php
51                exit();
52        }
53               
54        //SWITCH OUT THE SHIPPING METHOD
55        switch($_GET["shipvia"]){
56                case "UPS Ground (Res)":
57                        $shippingmethod="GNDRES";
58                break;
59                case "UPS Ground (Com)":
60                        $shippingmethod="GNDCOM";
61                break;
62                case "UPS 2nd Day Air":
63                        $shippingmethod="2DA";
64                break;
65                case "UPS 3 Day Select":
66                        $shippingmethod="3DS";
67                break;
68                case "UPS Next Day Air":
69                        $shippingmethod="1DA";
70                break;
71        }
72       
73        $total_pckges=0;
74        $total_shipping=0;
75        $total_weight=0;
76
77        foreach($_GET as $name => $item){
78       
79                if(strpos($name,"LI")!==false){
80               
81                        //convert data to array                 
82                        $lineitem = explode("::",$item);
83
84                        //grab info from product.                       
85                        $querystatement="SELECT isprepackaged,weight,packagesperitem FROM products WHERE id=".trim($lineitem[0]);
86                        $queryresult=$db->query($querystatement);
87
88                        $therecord=$db->fetchArray($queryresult);
89                        $therecord["quantity"] = trim($lineitem[1]) ;
90                       
91                        //get the pricing
92                        if($therecord["isprepackaged"]){
93
94                                $UPSreturn = UPSprice($shippingmethod,SHIPPING_POSTALCODE,$_GET["postalcodeto"],$therecord["weight"]);
95                                if (!$UPSreturn["success"])
96                                        $shipping=0; 
97                                else 
98                                        $shipping=$UPSreturn["charge"];
99                                       
100                                $total_shipping+=($shipping*$therecord["quantity"]);
101                               
102                        } else {
103                       
104                                // for non prepackaged add up total weight and total packages
105                                $total_pckges+=$therecord["quantity"]*$therecord["packagesperitem"];
106                                $total_weight+=$therecord["quantity"]*$therecord["weight"];
107                               
108                        }//end if
109                       
110                }//end if
111               
112        }//endforeach
113       
114        $total_pckges=ceil($total_pckges);
115
116        if($total_pckges){
117                $avg_weight=$total_weight/$total_pckges;
118                //check for errors on price
119                $UPSreturn=UPSprice($shippingmethod,SHIPPING_POSTALCODE,$_GET["postalcodeto"],$avg_weight);
120                if (!$UPSreturn["success"]) $shipping=0; else $shipping=$UPSreturn["charge"];
121                        $total_shipping+=($shipping*$total_pckges);
122        }//end if
123       
124        //mark up
125        $total_shipping=$total_shipping*SHIPPING_MARKUP;
126       
127?>
128<response>
129        <value><?php echo $total_shipping?></value>
130</response>
Note: See TracBrowser for help on using the browser.
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.