/** * nv_shipping_price() * * @param mixed $weight * @param mixed $weight_unit * @param mixed $location_id * @param mixed $carrier_id * @param mixed $config_id * @return */ function nv_shipping_price($weight, $weight_unit, $location_id, $shops_id, $carrier_id) { global $db, $db_config, $module_data, $pro_config; $array_weight_config = array(); $array_location_config = array(); $price = array(); $sql = 'SELECT config_id FROM ' . $db_config['prefix'] . '_' . $module_data . '_shops_carrier WHERE shops_id = ' . $shops_id . ' AND carrier_id = ' . $carrier_id; $result = $db->query($sql); list($config_id) = $result->fetch(3); if ($config_id) { $sql = 'SELECT iid FROM ' . $db_config['prefix'] . '_' . $module_data . '_carrier_config_location WHERE cid = ' . $config_id . ' AND lid = ' . $location_id; $result = $db->query($sql); list($iid) = $result->fetch(3); if ($iid) { // Weight config $sql = 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_carrier_config_weight WHERE iid = ' . $iid . ' ORDER BY weight'; $result = $db->query($sql); while ($array_weight = $result->fetch()) { $array_weight_config[$array_weight['iid']][] = $array_weight; } } } if (!empty($array_weight_config)) { foreach ($array_weight_config as $weight_config) { foreach ($weight_config as $config) { $config['weight'] = nv_weight_conversion($config['weight'], $config['weight_unit'], $weight_unit); if ($weight < $config['weight']) { $price = nv_currency_conversion($config['carrier_price'], $config['carrier_price_unit'], $pro_config['money_unit']); break; } else { // Vuot muc gia cau hinh } } } } return $price; }
$weight_total = 0; while (list($id, $listcatid, $publtime, $title, $alias, $hometext, $homeimgalt, $homeimgfile, $homeimgthumb, $product_price, $unit, $money_unit, $discount_id, $product_weight, $weight_unit) = $result->fetch(3)) { if ($homeimgthumb == 1) { $thumb = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 2) { $thumb = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 3) { $thumb = $homeimgfile; } else { $thumb = NV_BASE_SITEURL . 'themes/' . $module_info['template'] . '/images/' . $module_file . '/no-image.jpg'; } if ($pro_config['active_price'] == '0') { $discount_id = $product_price = 0; } $num = $_SESSION[$module_data . '_cart'][$id]['num']; $weight_total += nv_weight_conversion($product_weight, $weight_unit, $pro_config['weight_unit'], $num); $group = $_SESSION[$module_data . '_cart'][$id]['group']; $data_content[] = array('id' => $id, 'publtime' => $publtime, 'title' => $title, 'alias' => $alias, 'hometext' => $hometext, 'homeimgalt' => $homeimgalt, 'homeimgthumb' => $thumb, 'product_price' => $product_price, 'discount_id' => $discount_id, 'product_unit' => $unit, 'money_unit' => $money_unit, 'group' => $group, 'link_pro' => $link . $global_array_shops_cat[$listcatid]['alias'] . '/' . $alias . $global_config['rewrite_exturl'], 'num' => $num); ++$i; } } $data_order['weight_total'] = $weight_total; // Cảnh báo đang sửa đơn hàng if (isset($_SESSION[$module_data . '_order_info']) and !empty($_SESSION[$module_data . '_order_info'])) { $order_info = $_SESSION[$module_data . '_order_info']; $lang_module['order_submit_send'] = $lang_module['order_edit']; } if ($i == 0) { Header('Location: ' . nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=cart', true)); exit; } else {