예제 #1
0
 /**
  * Get shipping total.
  */
 function get_shipping_total($cart, $options = null)
 {
     if ($options['discount']) {
         // Override with stored discount value.
         if (is_numeric($cart['shipping_discount'])) {
             return $cart['shipping_discount'];
         } else {
             if ($cart['order']['id'] && is_numeric($cart['order']['shipping_discount'])) {
                 return $cart['order']['shipping_discount'];
             }
         }
     } else {
         // Override with stored total value.
         if (is_numeric($cart['shipping_total'])) {
             return $cart['shipping_total'];
         } else {
             if ($cart['order']['id'] && is_numeric($cart['order']['shipping_total'])) {
                 return $cart['order']['shipping_total'];
             }
         }
     }
     $method_name = $cart['order']['shipping']['method'];
     // Get fresh methods/prices.
     $methods = Carts::get_shipping_methods($cart);
     // Find the selected method and price.
     foreach ((array) $methods as $method) {
         if ($method['name'] == $method_name) {
             // Discount total?
             if ($options['discount']) {
                 return $method['discount'];
             }
             $total = $method['price'];
             // Adjust total if applicable.
             return $total + $cart['shipping_fee'];
         }
     }
     return null;
 }