hjkhghtjhjjhjhjhjhjjhjhjjhrrtrtoirh
bnmbertsurrttrtrtrtrjhjhjjhjhhjhjhjhf'tdfg
/
home
/
u506006416
/
domains
/
crystalmiracle.co.in
/
public_html
/
Upload FileeE
HOME
<?php include_once("admin/include/config.php"); $sel_obj = new config(); $temp_session_id = session_id(); /*============= Offers Discount Function =============*/ function offers_discount($p_id='', $qty=''){ $sel_obj = new config(); $p_cond="`p_id`=".$p_id; $p_qu=$sel_obj->display_rcd("product",$p_cond); if(is_array($p_qu) AND !empty($p_qu)) { foreach($p_qu as $p_da) { } } $offer_array = array( 'offer_discount_amount' => 0 , 'offer_name' => NULL, 'shipping_price' => $p_da['shipping_price'], 'packaging_price' => $p_da['packaging_price'] ); $total_amount = $p_da['d_price']*$qty; $offers = json_decode($p_da['offers'], true); if (!empty($offers)) { foreach ($offers as $offer) { if ($qty >= $offer['offer_qty']) { if ($offer['offer_discount_type']=="percent") { $offer_discount_amount = ($offer['offer_discount']*$total_amount)/100; } if ($offer['offer_discount_type']=="flat") { $offer_discount_amount = $offer['offer_discount']; } if ($offer['free_delivery']==1) { $shipping_price = 0; }else{ $shipping_price = $p_da['shipping_price']; } if ($offer['free_packaging']==1) { $packaging_price = 0; }else{ $packaging_price = $p_da['packaging_price']; } $offer_array = array( 'offer_discount_amount' => round($offer_discount_amount) , 'offer_name' => $offer['offer_title'], 'shipping_price' => $shipping_price, 'packaging_price' => $packaging_price ); } } return $offer_array; }else { $offer_array = array( 'offer_discount_amount' => 0 , 'offer_name' => NULL, 'shipping_price' => $p_da['shipping_price'], 'packaging_price' => $p_da['packaging_price'] ); return $offer_array; } } // $off_array = offers_discount(1050, 8); // print_r($off_array); // die(); /*====================================================*/ if (isset($_POST['temp_id_s']) AND isset($temp_session_id)) { $status = '1'; $temp_id = $sel_obj->validation($_POST['temp_id_s']); $p_id = $sel_obj->validation($_POST['product_id_s']); $p_name = $sel_obj->validation($_POST['p_name_s']); $p_code = $sel_obj->validation($_POST['p_code_s']); $img = $sel_obj->validation($_POST['p_img_s']); $quantity = $sel_obj->validation($_POST['qtn_s']); $price = $sel_obj->validation($_POST['r_p_s']); $d_price = $sel_obj->validation($_POST['o_p_s']); $gst = $sel_obj->validation($_POST['gst_s']); $shipping_price = $sel_obj->validation($_POST['shipping_price_s']); $packaging_price = $sel_obj->validation($_POST['packaging_price_s']); $col_val = array( 'temp_id' => $temp_id, 'p_id' => $p_id, 'p_name' => $p_name, 'p_code' => $p_code, 'img' => $img, 'quantity' => $quantity, 'price' => $price, 'd_price' => $d_price, 'gst' => $gst, 'status' => $status, 'shipping_price' => $shipping_price, 'packaging_price' => $packaging_price ); $where_con1 = "`status` = '1' and `p_id`='$p_id' and `temp_id`=" . "'$temp_id'"; $all_count_where = $sel_obj->all_count_row('temp_cart', $where_con1); /*--------- Product Info ----------*/ $p_condition="`p_id`=".$p_id; $p_query=$sel_obj->display_rcd("product",$p_condition); if(is_array($p_query) AND !empty($p_query)) { foreach($p_query as $p_data) { } } if ($p_data['max_qty_per_user'] > $p_data['quan_available']) { $max_qty_per_user = $p_data['quan_available']; }else{ $max_qty_per_user = $p_data['max_qty_per_user']; } /*-------------------------------------*/ if ($all_count_where > 0) { $fetch_product = $sel_obj->all_fetch("temp_cart", array( 'p_id' => $p_id, 'temp_id' => $temp_id )); if (is_array($fetch_product) || is_object($fetch_product)) { foreach ($fetch_product as $old_qtn) { } $qtn = $old_qtn->quantity; $qtn_count = $qtn + 1; } /*------- Check Max Qty per user -----*/ if ($qtn_count > $max_qty_per_user) { echo $max_qty_per_user." units "; exit(); } /*---------- Check Offer Discount -------------*/ $off_array = offers_discount($p_id, $qtn_count); /*---------------------------------------------*/ $update_query = $sel_obj->update('temp_cart', array( 'quantity' => $qtn_count, 'shipping_price' => $off_array['shipping_price'], 'packaging_price' => $off_array['packaging_price'], 'offer_discount' => $off_array['offer_discount_amount'], 'offer_name' => $off_array['offer_name'], ), array( 'p_id' => $p_id, 'temp_id' => $temp_id )); if ($update_query == true) echo $update_query; } else { /*------- Check Max Qty per user -----*/ if ($quantity > $max_qty_per_user) { echo $max_qty_per_user." units "; exit(); } /*---------- Check Offer Discount -------------*/ $off_array = offers_discount($p_id, $quantity); $col_val['shipping_price'] = $off_array['shipping_price']; $col_val['packaging_price'] = $off_array['packaging_price']; $col_val['offer_discount'] = $off_array['offer_discount_amount']; $col_val['offer_name'] = $off_array['offer_name']; /*---------------------------------------------*/ $row = $sel_obj->insert('temp_cart', $col_val); if ($row == true) { $delete_query = $sel_obj->delete_all("shiping"); echo $row; } } } ?> <?php if (isset($_POST['p_id'])) { $status1 = "1"; $temp_id1 = $sel_obj->validation($_POST['temp_id']); $p_code1 = $sel_obj->validation($_POST['p_code']); $p_img1 = $sel_obj->validation($_POST['img']); $product_id1 = $sel_obj->validation($_POST['p_id']); $gst1 = $sel_obj->validation($_POST['gst']); $r_p1 = $sel_obj->validation($_POST['r_price']); $o_p1 = $sel_obj->validation($_POST['d_price']); $p_name1 = $sel_obj->validation($_POST['p_name']); $qtn1 = $sel_obj->validation($_POST['quantity']); $shipping_price1 = $sel_obj->validation($_POST['shipping_price']); $packaging_price1 = $sel_obj->validation($_POST['packaging_price']); $single_product = array( 'temp_id' => $temp_id1, 'p_id' => $product_id1, 'p_name' => $p_name1, 'p_code' => $p_code1, 'img' => $p_img1, 'quantity' => $qtn1, 'price' => $r_p1, 'd_price' => $o_p1, 'gst' => $gst1, 'status' => $status1, 'shipping_price' => $shipping_price1, 'packaging_price' => $packaging_price1 ); // print_r($single_product); $single_product_cond = "`status` = '1' and `p_id`='$product_id1' and `temp_id`=" . "'$temp_id1'"; $all_count_single_product = $sel_obj->all_count_row('temp_cart', $single_product_cond); /*--------- Product Info ----------*/ $p_condition="`p_id`=".$product_id1; $p_query=$sel_obj->display_rcd("product",$p_condition); if(is_array($p_query) AND !empty($p_query)) { foreach($p_query as $p_data) { } } if ($p_data['max_qty_per_user'] > $p_data['quan_available']) { $max_qty_per_user = $p_data['quan_available']; }else{ $max_qty_per_user = $p_data['max_qty_per_user']; } /*-------------------------------------*/ if ($all_count_single_product > 0) { $fetch_product = $sel_obj->all_fetch("temp_cart", array( 'p_id' => $product_id1, 'temp_id' => $temp_id1 )); if (is_array($fetch_product) || is_object($fetch_product)) { foreach ($fetch_product as $old_qtn) { } $qtn = $old_qtn->quantity; $qtn_count = $qtn + $qtn1; } /*------- Check Max Qty per user -----*/ if ($qtn_count > $max_qty_per_user) { echo $max_qty_per_user." units "; exit(); } /*---------- Check Offer Discount -------------*/ $off_array = offers_discount($product_id1, $qtn_count); /*---------------------------------------------*/ $update_query = $sel_obj->update('temp_cart', array( 'quantity' => $qtn_count, 'shipping_price' => $off_array['shipping_price'], 'packaging_price' => $off_array['packaging_price'], 'offer_discount' => $off_array['offer_discount_amount'], 'offer_name' => $off_array['offer_name'], ), array( 'p_id' => $product_id1, 'temp_id' => $temp_id1 )); if ($update_query == true) echo $update_query; } else { /*------- Check Max Qty per user -----*/ if ( $qtn1 > $max_qty_per_user) { echo $max_qty_per_user." units "; exit(); } /*---------- Check Offer Discount -------------*/ $off_array = offers_discount($product_id1, $qtn1); $single_product['shipping_price'] = $off_array['shipping_price']; $single_product['packaging_price'] = $off_array['packaging_price']; $single_product['offer_discount'] = $off_array['offer_discount_amount']; $single_product['offer_name'] = $off_array['offer_name']; /*---------------------------------------------*/ $row1 = $sel_obj->insert('temp_cart', $single_product); if ($row1 == true) { $delete_query = $sel_obj->delete_all("shiping"); echo $row1; } } } // else // { // echo "error"; // } ?> <?php if (isset($_GET['temp_item'])) { $temp_idd = $sel_obj->validation($_GET['temp_id']); $where_con = "`status` = 1 AND `temp_id`=" . "'$temp_idd'"; echo $all_count_where = $sel_obj->all_count_row('temp_cart', $where_con); } ?> <?php /*------- Delete Cart ------*/ if (isset($_GET['remove'])) { $redirect_url = $_SERVER['HTTP_REFERER']; $remove = base64_decode($_GET['remove']); $where_con_cart = "`status` = 1 AND `id`=" . "'$remove'"; $all_count_cart = $sel_obj->all_count_row('temp_cart', $where_con_cart); //print_r($all_count_cart); die(); if ($all_count_cart) { $where = array( 'id' => $remove, 'status' => 1 ); if ($sel_obj->delete("temp_cart", $where)) { $delete_query = $sel_obj->delete_all("shiping"); } } echo "<script>window.location.href='".$redirect_url."'</script>"; } /*---------- Save for later ------*/ if (isset($_GET['savetolater'])) { $redirect_url = $_SERVER['HTTP_REFERER']; $savetolater = base64_decode($_GET['savetolater']); $where_con_cart = "`status` = 1 AND `id`=" . "'$savetolater'"; $all_count_cart = $sel_obj->all_count_row('temp_cart', $where_con_cart); //print_r($all_count_cart); die(); if ($all_count_cart) { $where = array( 'id' => $savetolater, 'status' => 1 ); $update_cart = $sel_obj->update('temp_cart',array('status' => 2),$where); } echo "<script>window.location.href='".$redirect_url."'</script>"; } /*---------- Move to cart ------------*/ if (isset($_GET['movetocart'])) { $redirect_url = $_SERVER['HTTP_REFERER']; $movetocart = base64_decode($_GET['movetocart']); $where_con_cart = "`status` = 2 AND `id`=" . "'$movetocart'"; $all_count_cart = $sel_obj->all_count_row('temp_cart', $where_con_cart); //print_r($all_count_cart); die(); if ($all_count_cart) { $where = array( 'id' => $movetocart, 'status' => 2 ); $update_cart = $sel_obj->update('temp_cart',array('status' => 1),$where); } echo "<script>window.location.href='".$redirect_url."'</script>"; } /*--------- Remove from saved items --------*/ if (isset($_GET['removesaveditem'])) { $redirect_url = $_SERVER['HTTP_REFERER']; $removesaveditem = base64_decode($_GET['removesaveditem']); $where_con_cart = "`status` = 2 AND `id`=" . "'$removesaveditem'"; $all_count_cart = $sel_obj->all_count_row('temp_cart', $where_con_cart); //print_r($all_count_cart); die(); if ($all_count_cart) { $where = array( 'id' => $removesaveditem, 'status' => 2 ); if ($sel_obj->delete("temp_cart", $where)) { $delete_query = $sel_obj->delete_all("shiping"); } } echo "<script>window.location.href='".$redirect_url."'</script>"; } /*-----------------------------------*/ ?> <?php if (isset($_POST['productkey'])) { $p_id = $sel_obj->validation($_POST['productkey']); $qnt = $sel_obj->validation($_POST['plusqunt']); $id = $sel_obj->validation($_POST['id']); /*--------- Product Info ----------*/ $p_condition="`p_id`=".$p_id; $p_query=$sel_obj->display_rcd("product",$p_condition); if(is_array($p_query) AND !empty($p_query)) { foreach($p_query as $p_data) { } } if ($p_data['max_qty_per_user'] > $p_data['quan_available']) { $max_qty_per_user = $p_data['quan_available']; }else{ $max_qty_per_user = $p_data['max_qty_per_user']; } /*------- Check Max Qty per user -----*/ if ($qnt > $max_qty_per_user) { echo $max_qty_per_user." units "; exit(); } /*-------------------------------------*/ if (is_numeric($id)) { $where_con_cart1 = "`status` = 1 AND `id`=" . "'$id'"; $all_count_cart1 = $sel_obj->all_count_row('temp_cart', $where_con_cart1); if ($all_count_cart1) { /*---------- Check Offer Discount -------------*/ $off_array = offers_discount($p_id, $qnt); /*---------------------------------------------*/ if ($sel_obj->update("temp_cart", array( 'quantity' => $qnt, 'shipping_price' => $off_array['shipping_price'], 'packaging_price' => $off_array['packaging_price'], 'offer_discount' => $off_array['offer_discount_amount'], 'offer_name' => $off_array['offer_name'], ), array( 'id' => $id ))) { $delete_query = $sel_obj->delete_all("shiping"); echo 1; } } } } ?> <?php if (isset($_POST['state']) AND !empty($_POST['subtotal']) AND is_numeric($_POST['subtotal']) AND !empty($_POST['tempid'])) { $shipping_cost_gst = ""; $state = $sel_obj->validation($_POST['state']); $subtotal = $sel_obj->validation($_POST['subtotal']); $tempid = $sel_obj->validation($_POST['tempid']); $user_id = $sel_obj->validation($_POST['user_id']); if ($subtotal > 3000) { $shippingcost = 67; $discount_percentage = 40; $shipping_cost_gst = $sel_obj->get_percentage($shippingcost, $discount_percentage); $insert_shiping = array( 'temp_id' => $tempid, 'user_id' => $user_id, 'shiping_cost' => $shipping_cost_gst ); $delete_query = $sel_obj->delete_all("shiping"); if ($delete_query) { $sel_obj->insert("shiping", $insert_shiping); } } elseif ($subtotal < 3000) { $shippingcost = 67; $discount_percentage = 18; $shipping_cost_gst = $sel_obj->get_percentage($shippingcost, $discount_percentage); $total_shiping = ($shippingcost + $shipping_cost_gst); $insert_shiping = array( 'temp_id' => $tempid, 'user_id' => $user_id, 'shiping_cost' => $total_shiping ); $delete_query = $sel_obj->delete_all("shiping"); if ($delete_query) { $sel_obj->insert("shiping", $insert_shiping); } } } if (isset($_POST['pincode'])) { $pincode = $sel_obj->validation($_POST['pincode']); $where_pin = "`pincode`=" . "'$pincode'"; $all_count_pincode = $sel_obj->all_count_row('pincode', $where_pin); if ($all_count_pincode == 1) { ?> <p class="text-success font-weight-bold"> Item delivery available at <?php echo $pincode; ?></p> <?php } else { ?> <p class="text-danger">We are not available at this (<?php echo $pincode; ?>) location.<br> Please try another Pincode.</p> <?php } } /*============== Rating functionality ===========*/ if (isset($_POST['submit_rating'])) { // print_r($_POST); // echo "<div class='alert alert-success' role='alert'> Thanks for rating us </div>"; die(); $message = ""; if ($_POST['rating'] == "") { $message = "<div class='alert alert-danger' role='alert'> Please select star </div>"; echo $message; exit(); } $check_data = array( 'user_id' => $_POST['user_id'], 'product_id' => $_POST['product_id'] ); $rate_data = array( 'rating' => $_POST['rating'], 'comment' => $_POST['comment'], 'user_id' => $_POST['user_id'], 'product_id' => $_POST['product_id'] ); $check_rating = $sel_obj->all_fetch("tbl_rating", $check_data); if ($check_rating != 0) { $update_rating = $sel_obj->update('tbl_rating', $rate_data, $check_data); $message = "<div class='alert alert-success' role='alert'> Updated Successfully </div>"; } else { $rate_data['created_at'] = date('Y-m-d H:i:s'); $insert_rating = $sel_obj->insert('tbl_rating', $rate_data); $message = "<div class='alert alert-success' role='alert'> Thanks for rating us </div>"; } echo $message; } ?>