示例#1
0
 public function shipping()
 {
     if (isset($this->amount->shipping)) {
         return $this->amount->shipping;
     } elseif (isset($this->order->shipping)) {
         if (isset($this->order->shipping->method)) {
             $shipping = new Shipping('UPS', $this->order->shipping->zip, $this->order->shipping->country, $this->order->basket);
             $shipping->setMethod($this->order->shipping->method);
             if (!is_numeric($amount = $shipping->amount())) {
                 $this->error = $amount;
                 return 0;
             }
             if (isset($this->amount->discount['shippingDiscount'])) {
                 $amount = $amount - $amount * 0.01 * $this->amount->discount['shippingDiscount'];
             }
             //add 35% to the shipping cost that UPS returns
             $shipping_cost = $amount + 0.35 * $amount;
             $this->amount->shipping = $shipping_cost;
             return $shipping_cost;
         } else {
             return 0;
         }
     } else {
         return 0;
     }
 }
示例#2
0
 public function getShippingRate()
 {
     $cart =& $this->getProducts();
     $zip = $_POST['destZip'];
     $country = $_POST['destCountry'];
     $method = $_POST['method'];
     $shipping = new Shipping('UPS', $zip, $country, $cart);
     $shipping->setMethod($method);
     $amount = $shipping->amount();
     //add 35% to the shipping cost that UPS returns
     $amount = sprintf("%6.2f", $amount + 0.35 * $amount);
     $cart->clear();
     die(trim($amount));
 }