reset(); $d->query("select soluong,gia,id_product from #_order_detail where id_order='".$id_order."'"); $all_cart = $d->result_array(); $max=count($all_cart); $sum=0; for($i=0;$i<$max;$i++){ $pid=$all_cart[$i]['id_product']; $q=$all_cart[$i]['soluong']; $price=get_price($pid); $sum+=$price*$q; } return $sum ; } function get_product_name($pid){ global $d, $row,$lang; $sql = "select ten_$lang from #_product where id='".$pid."'"; $d->query($sql); $row = $d->fetch_array(); return $row['ten_'.$lang]; } function get_product_kd($pid){ global $d, $row,$lang; $sql = "select tenkhongdau from #_product where id='".$pid."'"; $d->query($sql); $row = $d->fetch_array(); return $row['tenkhongdau']; } function get_hinh($pid){ global $d, $row; $sql = "select thumb from table_product where id=$pid"; $d->query($sql); $row = $d->fetch_array(); return $row['thumb']; } function get_hinh_mau($pid){ global $d, $row; $sql = "select photo from table_thuoctinh where id=$pid"; $d->query($sql); $row = $d->fetch_array(); return $row['photo']; } function get_price($pid){ global $d, $row; $sql = "select giaban from table_product where id='".$pid."'"; $d->query($sql); $row = $d->fetch_array(); return $row['giaban']; } function get_thumb($pid){ global $d, $row; $sql = "select thumb from table_product where id='".$pid."' "; $d->query($sql); $row = $d->fetch_array(); return $row['thumb']; } function remove_product($pid) { $pid = intval($pid); $max = count($_SESSION['cart']); for ($i = 0; $i < $max; $i++) { if ($pid == $_SESSION['cart'][$i]['productid']) { unset($_SESSION['cart'][$i]); break; } } $_SESSION['cart'] = array_values($_SESSION['cart']); } function remove_pro_thanh($pid){ $pid=intval($pid); $max=count($_SESSION['cart']); for($i=0;$i<$max;$i++){ if($pid==$_SESSION['cart'][$i]['productid']){ unset($_SESSION['cart'][$i]); break; } } $_SESSION['cart']=array_values($_SESSION['cart']); redirect('thanh-toan.html'); } function get_order_total(){ $max=count($_SESSION['cart']); $sum=0; for($i=0;$i<$max;$i++){ $pid=$_SESSION['cart'][$i]['productid']; $q=$_SESSION['cart'][$i]['qty']; $price=get_price($pid); $sum+=$price*$q; } return $sum; } function addtocart($pid,$size,$mau,$q){ if($pid<1 or $q<1) return; if(is_array($_SESSION['cart'])){ if(product_exists_sm($pid,$q,$size,$mau)) return 0; $max=count($_SESSION['cart']); $_SESSION['cart'][$max]['productid']=$pid; $_SESSION['cart'][$max]['idsize']=$size; $_SESSION['cart'][$max]['idmau']=$mau; $_SESSION['cart'][$max]['qty']=$q; return count($_SESSION['cart']); } else{ $_SESSION['cart']=array(); $_SESSION['cart'][0]['productid']=$pid; $_SESSION['cart'][0]['idsize']=$size; $_SESSION['cart'][0]['idmau']=$mau; $_SESSION['cart'][0]['qty']=$q; return count($_SESSION['cart']); } } function product_exists_sm($pid,$q,$size,$mau){ $pid=intval($pid); $size=$size; $mau=$mau; $max=count($_SESSION['cart']); $flag=0; for($i=0;$i<$max;$i++){ if( ($pid==$_SESSION['cart'][$i]['productid'])){ $_SESSION['cart'][$i]['qty'] = $_SESSION['cart'][$i]['qty'] + $q; $flag=1; break; } } return $flag; } function product_exists($pid,$q){ $pid=intval($pid); $max=count($_SESSION['cart']); $flag=0; for($i=0;$i<$max;$i++){ if($pid==$_SESSION['cart'][$i]['productid']){ $_SESSION['cart'][$i]['qty'] = $_SESSION['cart'][$i]['qty'] + $q; $flag=1; break; } } return $flag; } function get_size($size){ global $d, $row,$lang; $sql = "select ten_$lang from table_thuoctinh where id='".$size."'"; $d->query($sql); $row = $d->fetch_array(); return $row['ten_'.$lang]; } function addtocart2($pid,$size,$mau,$q){ if($pid<1 or $q<1) return; if(is_array($_SESSION['cart'])){ if(product_exists_sm2($pid,$q,$size,$mau)) return 0; $max=count($_SESSION['cart']); $_SESSION['cart'][$max]['productid']=$pid; $_SESSION['cart'][$max]['idsize']=$size; $_SESSION['cart'][$max]['idmau']=$mau; $_SESSION['cart'][$max]['qty']=$q; return count($_SESSION['cart']); } else{ $_SESSION['cart']=array(); $_SESSION['cart'][0]['productid']=$pid; $_SESSION['cart'][0]['idsize']=$size; $_SESSION['cart'][0]['idmau']=$mau; $_SESSION['cart'][0]['qty']=$q; return count($_SESSION['cart']); } } function product_exists_sm2($pid,$q,$size,$mau){ $pid=intval($pid); $size=$size; $mau=$mau; $max=count($_SESSION['cart']); $flag=0; for($i=0;$i<$max;$i++){ if( ($pid==$_SESSION['cart'][$i]['productid']) && ($size==$_SESSION['cart'][$i]['idsize']) && ($mau==$_SESSION['cart'][$i]['idmau']) ){ $_SESSION['cart'][$i]['qty'] = $q; $flag=1; break; } } return $flag; } ?> Gạch Giả Cổ Có Mấy Loại - Kích Thước Ra Sao?
Hotline: 0933503683
Zalo

icon-hotlineHotline: 0933503683

icon-emailEmail: info@linhnhon.com

icon-giolvGiờ làm việc: 7:30 - 17:00

icon-cartGiỏ hàng 0

Tin tức

Gạch Giả Cổ Có Mấy Loại - Kích Thước Ra Sao?