diff --git a/.idea/ecommerce1.iml b/.idea/ecommerce1.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/ecommerce1.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0f60086 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/admin/del_order.php b/admin/del_order.php new file mode 100644 index 0000000..c74bbf5 --- /dev/null +++ b/admin/del_order.php @@ -0,0 +1,20 @@ +alert("Deleted Successfully");'; + header("refresh:2;URL=index.php?view_orders"); + } + else + { + echo ''; + } +} + + +?> \ No newline at end of file diff --git a/admin/functions/functions.php b/admin/functions/functions.php new file mode 100644 index 0000000..c0e15ea --- /dev/null +++ b/admin/functions/functions.php @@ -0,0 +1,128 @@ + $cat_title "; + } +} + +//getting Brands +function getBrands(){ + global $con; + $get_brands = "select * from brands"; + $run_brands = mysqli_query($con, $get_brands); + while ($row_brands= mysqli_fetch_array($run_brands)){ + $brand_id = $row_brands['brand_id']; + $brand_title = $row_brands['brand_title']; + echo "
  • $brand_title
  • "; + } +} + +function getPro($flag = ''){ + global $con; + $get_pro = ""; + if(!isset($_GET['cat']) && !isset($_GET['brand']) && !isset($_GET['search'])) { + if($flag == 'all_products') + $get_pro = "select * from products"; + else + $get_pro = "select * from products order by RAND() limit 0,6"; + } else if(isset($_GET['cat'])){ + $pro_cat_id = $_GET['cat']; + $get_pro = "select * from products where pro_cat = '$pro_cat_id'"; + } else if(isset($_GET['brand'])){ + $pro_brand_id = $_GET['brand']; + $get_pro = "select * from products where pro_brand = '$pro_brand_id'"; + } else if(isset($_GET['search'])){ + $search_query = $_GET['user_query']; + $get_pro = "select * from products where pro_keywords like '%$search_query%'"; + } + $run_pro = mysqli_query($con,$get_pro); + $count_pro = mysqli_num_rows($run_pro); + if($count_pro==0){ + echo "

    No Product found in selected criteria

    "; + } + while($row_pro = mysqli_fetch_array($run_pro)){ + $pro_id = $row_pro['pro_id']; + $pro_cat = $row_pro['pro_cat']; + $pro_brand = $row_pro['pro_brand']; + $pro_title = $row_pro['pro_title']; + $pro_price = $row_pro['pro_price']; + $pro_image = $row_pro['pro_image']; + echo " +
    +

    $pro_title

    + +

    Rs $pro_price/-

    + Details + +
    + "; + } +} +//getting the user IP address +function getIp() { + $ip = $_SERVER['REMOTE_ADDR']; + + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { + $ip = $_SERVER['HTTP_CLIENT_IP']; + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; + } + return $ip; +} +//creating the shopping cart +function cart(){ + if(isset($_GET['add_cart'])){ + global $con; + $ip = getIp(); + $pro_id = $_GET['add_cart']; + $check_pro = "select * from cart where ip_add = '$ip' AND p_id='$pro_id '"; + $run_check = mysqli_query($con,$check_pro); + if(mysqli_num_rows($run_check)>0){ + echo ""; + } else { + $insert_pro = "insert into cart (p_id, ip_add) VALUES + ('$pro_id','$ip')"; + $run_pro = mysqli_query($con,$insert_pro); + if($run_pro) + header('location:'.$_SERVER['PHP_SELF']); + } + } +} +//getting the total added items. +function total_items(){ + global $con; + $ip = getIp(); + $get_items = "select * from cart where ip_add='$ip'"; + $run_items = mysqli_query($con,$get_items); + $count_items = 0; + while($row = mysqli_fetch_array($run_items)) + $count_items += $row['qty']; + echo $count_items; +} +//getting the total price of the items in the cart +function total_price(){ + global $con; + $ip = getIp(); + $total = 0; + $sel_price = "select * from cart where ip_add = '$ip'"; + $run_price = mysqli_query($con,$sel_price); + while($cart_row = mysqli_fetch_array($run_price)){ + $pro_id = $cart_row['p_id']; + $pro_qty = $cart_row['qty']; + $pro_price = "select * from products where pro_id = '$pro_id'"; + $run_pro_price = mysqli_query($con, $pro_price); + while ($pro_row = mysqli_fetch_array($run_pro_price)){ + $pro_price = $pro_row['pro_price']; + $pro_price_all_items = $pro_price * $pro_qty; + $total += $pro_price_all_items; + } + } + echo 'Rs '.$total.'/-'; +} diff --git a/admin/index.php b/admin/index.php index 32c44e5..c4a1739 100644 --- a/admin/index.php +++ b/admin/index.php @@ -121,6 +121,9 @@ else if(isset($_GET['del_customer'])){ include ('del_customer.php'); } + else if(isset($_GET['view_orders'])){ + include ('view_orders.php'); + } ?> diff --git a/admin/view_order.php b/admin/view_order.php new file mode 100644 index 0000000..00bfd82 --- /dev/null +++ b/admin/view_order.php @@ -0,0 +1,52 @@ +
    +
    +

    Products

    + + + + + + + + + + + + No Product found in selected criteria "; + } + else { + $i = 0; + while ($row_pro = mysqli_fetch_array($run_pro)) { + $pro_id = $row_pro['pro_id']; + $pro_cat = $row_pro['pro_cat']; + $pro_brand = $row_pro['pro_brand']; + $pro_title = $row_pro['pro_title']; + $pro_price = $row_pro['pro_price']; + $pro_image = $row_pro['pro_image']; + ?> + + + + + + + + + +
    #TitleImagePriceActions
    /- + Edit + + + Delete + +
    +
    +
    \ No newline at end of file diff --git a/admin/view_orders.php b/admin/view_orders.php new file mode 100644 index 0000000..4e55fa7 --- /dev/null +++ b/admin/view_orders.php @@ -0,0 +1,96 @@ + + + + + + My Online Shop + + + +

    Orders

    +
    + $qty) { + /*Way 2 to do */ + for($i =0; $i< sizeof($_POST['product_id']); $i++){ + $pro_id = $_POST['product_id'][$i]; + $qty = $_POST['qty'][$i]; + if($qty > 0) { + $update_qty = "update cart set qty='$qty' where p_id='$pro_id' AND ip_add='$ip'"; + $run_qty = mysqli_query($con, $update_qty); + } + } + if(isset($_POST['remove'])) { + foreach ($_POST['remove'] as $remove_id) { + $del_pro = "delete from cart where p_id='$remove_id' AND ip_add='$ip'"; + $run_del = mysqli_query($con, $del_pro); + } + } + header('location: '.$_SERVER['PHP_SELF']); + } + if(isset($_POST['continue'])){ + header('location: index.php'); + } + ?> +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    Product(s) Quantity Unit Price Items Total Actions
    +
    + +
    + + " class="btn btn-danger"> + Delete + +
    Sub Total:
    +
    + + \ No newline at end of file