Example #1
0
 public static function updateShippingCost($shipping_cost)
 {
     $context = Context::getContext();
     $id_carrier = $context->cart->id_carrier;
     //            $msk_default_price = Configuration::get('PS_MSK_DEFAULT_PRICE');//1500;
     //            if(!$msk_default_price)$msk_default_price = 1500;
     //  $msk_decor_price = Configuration::get('PS_MSK_DECOR_PRICE');//350;
     //            if(!$msk_decor_price)$msk_decor_price = 350;
     $other_default_price = Configuration::get('PS_OTHER_DEFAULT_PRICE');
     //2500;
     if (!$other_default_price) {
         $other_default_price = 350;
     }
     //            $other_decor_price =  Configuration::get('PS_OTHER_DECOR_PRICE');//600;
     //            if(!$other_decor_price)$other_decor_price = 600;
     $flag_decor_only = false;
     if (!$id_carrier) {
         return $shipping_cost;
     }
     $carrier = new Carrier($id_carrier, $context->language->id);
     if (!is_object($carrier) && !$carrier->id_reference) {
         return $shipping_cost;
     }
     if (!in_array($carrier->delay, array('courier'))) {
         return $shipping_cost;
     }
     $products = $context->cart->getProducts();
     if (!is_array($products) || !count($products)) {
         return $shipping_cost;
     }
     //            foreach ($products as $product)
     //                if(!Category::inDecor($product['id_category_default']))
     //                    $flag_decor_only = true;
     if (isset($context->cookie->id_city)) {
         $city = new City($context->cookie->id_city, $context->language->id);
         $bigprice = 0;
         foreach ($products as $product) {
             $price = Category::PriceCategory($product['id_category_default'], $city->id_city, $city->is_msk);
             if ($price > $bigprice) {
                 $bigprice = $price;
             }
         }
         if ($bigprice == 0) {
             $bigprice = $other_default_price;
         }
         //				if(!$flag_decor_only)
         //					$return = ($city->is_msk)?$msk_decor_price:$other_decor_price;
         //				else
         //					$return = ($city->is_msk)?$msk_default_price:$other_default_price;
     } else {
         $return = $shipping_cost;
     }
     return $bigprice;
 }