tribulant

Untitled

Apr 12th, 2011
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.70 KB | None | 0 0
  1. function products_shipping_total($total = null, $order_id = null, $order = null, $items = array(), $shipmethod = null) {
  2.         global $wpcoDb, $Order, $Item, $Product, $wpcoShipmethod;
  3.         $productsshipping = 0;
  4.        
  5.         if (!empty($order_id)) {           
  6.             if (!empty($order)) {              
  7.                 if (!empty($shipmethod)) {             
  8.                     if (!empty($items)) {                      
  9.                         foreach ($items as $item) {
  10.                             if (!empty($item -> product -> type) && $item -> product -> type == "tangible") {
  11.                                 //BEG additional product shipping cost
  12.                                 if (!empty($item -> product -> shipping) && $item -> product -> shipping == "Y") {
  13.                                     if (!empty($item -> product -> shiptype)) {
  14.                                         switch ($item -> product -> shiptype) {
  15.                                             case 'tiers'            :
  16.                                                 if (!empty($item -> product -> shiptiers) && is_array($item -> product -> shiptiers)) {
  17.                                                     $s = 1;
  18.                                                    
  19.                                                     foreach ($item -> product -> shiptiers as $tier) {                                                 
  20.                                                         if (($item -> count >= $tier['min'] && $item -> count <= $tier['max']) || $s == count($item -> product -> shiptiers)) {
  21.                                                             $productsshipping += ($tier['price'][$order -> shipmethod_id] * $item -> count);
  22.                                                             break 1;
  23.                                                         }
  24.                                                        
  25.                                                         $s++;
  26.                                                     }
  27.                                                 }
  28.                                                 break ;
  29.                                             case 'percentage'       :
  30.                                                 global $Product;
  31.                                            
  32.                                                 if (!empty($item -> product -> shippercentage) && is_array($item -> product -> shippercentage)) {
  33.                                                     if (!empty($item -> product -> shippercmethod)) {
  34.                                                         if ($item -> product -> shippercmethod == "wholesale" && !empty($item -> product -> wholesale)) {
  35.                                                             $newproductshipping = ((($item -> product -> wholesale * $item -> product -> shippercentage[$shipmethod -> id]) / 100) * $item -> count);
  36.                                                         } elseif ($item -> product -> shippercmethod == "fixed") {
  37.                                                             $newproductshipping = ((($Product -> unit_price($item -> product -> id, $item -> count, $item -> id, false, true) * $item -> product -> shippercentage[$shipmethod -> id]) / 100) * $item -> count);
  38.                                                         }
  39.                                                        
  40.                                                         if (!empty($newproductshipping)) {
  41.                                                             $productsshipping += $newproductshipping;  
  42.                                                         }
  43.                                                     }
  44.                                                 }
  45.                                                 break;
  46.                                             default                 :
  47.                                                 if (!empty($item -> product -> shipfixed) && is_array($item -> product -> shipfixed)) {
  48.                                                     $productsshipping += ($item -> product -> shipfixed[$shipmethod -> id] * $item -> count);
  49.                                                 }
  50.                                                 break ;
  51.                                         }
  52.                                     }
  53.                                 }
  54.                                 //END additional product shipping cost 
  55.                             }
  56.                         }
  57.                     }
  58.                 }
  59.             }
  60.         }
  61.        
  62.         return $productsshipping;
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment