Exemplo n.º 1
0
 static function getTotalPrice($products, $payment_method, $id_lang, $user)
 {
     $param = array('price' => 0, 'price_with_tax' => 0, 'weight' => 0, 'payment_price' => 0, 'delivery_price' => 0);
     foreach ($products as $id_product_param => $count) {
         $product = ProductModel::getProductIdentifyByParam($id_product_param, $id_lang, $user);
         $param['price'] += $product['price_array']['price'] * $count;
         $param['price_with_tax'] += $product['price_array']['price_with_tax'] * $count;
         $param['weight'] += $product['weight'] * $count;
     }
     ///$payment_method
     $param['payment_price'] = self::getPaymentPrice($payment_method, $param['price']);
     //		$delivery_price = ProductWeightModel::getPrice($weight);
     $param['delivery_price'] = ProductWeightModel::getPrice($param['weight']);
     $conf = NEnvironment::getContext()->parameters;
     if ($conf['DELIVERY_IS_WITH_TAX'] == 1) {
         $param['price'] += $param['delivery_price'] / (1 + $conf['DELIVERY_TAX'] / 100);
         $param['price_with_tax'] += $param['delivery_price'];
     } else {
         $param['price'] += $param['delivery_price'];
         $param['price_with_tax'] += $param['delivery_price'] * (1 + $conf['DELIVERY_TAX'] / 100);
     }
     return $param;
 }