-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dccdce0
commit 54aa305
Showing
34 changed files
with
1,283 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
<?php | ||
session_start(); | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', '1'); | ||
include "storescripts/connect_to_mysql.php"; | ||
?> | ||
<?php | ||
|
||
if (isset($_POST['pid'])) { | ||
$pid = $_POST['pid']; | ||
$wasFound = false; | ||
$i = 0; | ||
// If the cart session variable is not set or cart array is empty | ||
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { | ||
// RUN IF THE CART IS EMPTY OR NOT SET | ||
$_SESSION["cart_array"] = array(0 => array("item_id" => $pid, "quantity" => 1)); | ||
} else { | ||
// RUN IF THE CART HAS AT LEAST ONE ITEM IN IT | ||
foreach ($_SESSION["cart_array"] as $each_item) { | ||
$i++; | ||
while (list($key, $value) = each($each_item)) { | ||
if ($key == "item_id" && $value == $pid) { | ||
// That item is in cart already so let's adjust its quantity using array_splice() | ||
array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "quantity" => $each_item['quantity'] + 1))); | ||
$wasFound = true; | ||
} // close if condition | ||
} // close while loop | ||
} // close foreach loop | ||
if ($wasFound == false) { | ||
array_push($_SESSION["cart_array"], array("item_id" => $pid, "quantity" => 1)); | ||
} | ||
} | ||
header("location: cart.php"); | ||
exit(); | ||
} | ||
?> | ||
<?php | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Section 2 (if user chooses to empty their shopping cart) | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
if (isset($_GET['cmd']) && $_GET['cmd'] == "emptycart") { | ||
unset($_SESSION["cart_array"]); | ||
} | ||
?> | ||
<?php | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Section 3 (if user chooses to adjust item quantity) | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
if (isset($_POST['item_to_adjust']) && $_POST['item_to_adjust'] != "") { | ||
// execute some code | ||
$item_to_adjust = $_POST['item_to_adjust']; | ||
$quantity = $_POST['quantity']; | ||
$quantity = preg_replace('#[^0-9]#i', '', $quantity); // filter everything but numbers | ||
if ($quantity >= 100) { $quantity = 99; } | ||
if ($quantity < 1) { $quantity = 1; } | ||
if ($quantity == "") { $quantity = 1; } | ||
$i = 0; | ||
foreach ($_SESSION["cart_array"] as $each_item) { | ||
$i++; | ||
while (list($key, $value) = each($each_item)) { | ||
if ($key == "item_id" && $value == $item_to_adjust) { | ||
// That item is in cart already so let's adjust its quantity using array_splice() | ||
array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $item_to_adjust, "quantity" => $quantity))); | ||
} // close if condition | ||
} // close while loop | ||
} // close foreach loop | ||
} | ||
?> | ||
<?php | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Section 4 (if user wants to remove an item from cart) | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != "") { | ||
// Access the array and run code to remove that array index | ||
$key_to_remove = $_POST['index_to_remove']; | ||
if (count($_SESSION["cart_array"]) <= 1) { | ||
unset($_SESSION["cart_array"]); | ||
} else { | ||
unset($_SESSION["cart_array"]["$key_to_remove"]); | ||
sort($_SESSION["cart_array"]); | ||
} | ||
} | ||
?> | ||
<?php | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Section 5 (render the cart for the user to view on the page) | ||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
$cartOutput = ""; | ||
$cartTotal = ""; | ||
$pricetotal = ""; | ||
$pp_checkout_btn = ''; | ||
$product_id_array = ''; | ||
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { | ||
$cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>"; | ||
} else { | ||
// Start PayPal Checkout Button | ||
$pp_checkout_btn .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> | ||
<input type="hidden" name="cmd" value="_cart"> | ||
<input type="hidden" name="upload" value="1"> | ||
<input type="hidden" name="business" value="[email protected]">'; | ||
// Start the For Each loop | ||
$i = 0; | ||
foreach ($_SESSION["cart_array"] as $each_item) { | ||
$item_id = $each_item['item_id']; | ||
$sql = mysqli_query($conn, "SELECT * FROM `products` WHERE id='$item_id' LIMIT 1"); | ||
while ($row = mysqli_fetch_array($sql)) { | ||
$product_name = $row["product_name"]; | ||
$price = $row["price"]; | ||
$details = $row["details"]; | ||
} | ||
$pricetotal = ($price*$each_item['quantity']); | ||
$cartTotal = ($pricetotal+$cartTotal); | ||
setlocale(LC_MONETARY, "en_IN"); | ||
$pricetotal = money_format("₹%10i", $pricetotal); | ||
// Dynamic Checkout Btn Assembly | ||
$x = $i + 1; | ||
$pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '"> | ||
<input type="hidden" name="amount_' . $x . '" value="' . $price . '"> | ||
<input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '"> '; | ||
// Create the product array variable | ||
$product_id_array .= "$item_id-".$each_item['quantity'].","; | ||
// Dynamic table row assembly | ||
$cartOutput .= "<tr>"; | ||
$cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>'; | ||
$cartOutput .= '<td>' . $details . '</td>'; | ||
$cartOutput .= '<td>₹' . $price . '</td>'; | ||
$cartOutput .= '<td><form action="cart.php" method="post"> | ||
<input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" /> | ||
<input name="adjustBtn' . $item_id . '" type="submit" value="change" /> | ||
<input name="item_to_adjust" type="hidden" value="' . $item_id . '" /> | ||
</form></td>'; | ||
//$cartOutput .= '<td>' . $each_item['quantity'] . '</td>'; | ||
$cartOutput .= '<td>' . $pricetotal . '</td>'; | ||
$cartOutput .= '<td><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>'; | ||
$cartOutput .= '</tr>'; | ||
$i++; | ||
} | ||
setlocale(LC_MONETARY, "en_IN"); | ||
$cartTotal = money_format("₹%10i", $cartTotal); | ||
$cartTotal = "<div style='font-size:18px; margin-top:12px;' align='right'>Cart Total : ".$cartTotal." </div>"; | ||
// Finish the Paypal Checkout Btn | ||
$pp_checkout_btn .= '<input type="hidden" name="custom" value="' . $product_id_array . '"> | ||
<input type="hidden" name="notify_url" value="https://localhost/Webucator/ClassFiles/MyOnlineStore2/storescripts/my_ipn.php"> | ||
<input type="hidden" name="return" value="https://www.yoursite.com/checkout_complete.php"> | ||
<input type="hidden" name="rm" value="2"> | ||
<input type="hidden" name="cbt" value="Return to The Store"> | ||
<input type="hidden" name="cancel_return" value="https://www.yoursite.com/paypal_cancel.php"> | ||
<input type="hidden" name="lc" value="US"> | ||
<input type="hidden" name="currency_code" value="USD"> | ||
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - its fast, free and secure!"> | ||
</form>'; | ||
} | ||
?> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="https://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>Your Cart</title> | ||
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> | ||
</head> | ||
<body> | ||
<div align="center" id="mainWrapper"> | ||
<div valign="right" style="height: 300px; width: 1280px; color: #ffffff; | ||
background-image: url(style/bg1.jpg);></div> | ||
<?php include_once("template_header.php");?> | ||
<div id="pageContent"> | ||
<div style="margin:24px; text-align:left;"> | ||
|
||
<br /> | ||
<table width="100%" border="1" cellspacing="0" cellpadding="6"> | ||
<tr> | ||
<td width="18%" bgcolor="#C5DFFA"><strong>Product</strong></td> | ||
<td width="45%" bgcolor="#C5DFFA"><strong>Product Description</strong></td> | ||
<td width="10%" bgcolor="#C5DFFA"><strong>Unit Price</strong></td> | ||
<td width="9%" bgcolor="#C5DFFA"><strong>Quantity</strong></td> | ||
<td width="9%" bgcolor="#C5DFFA"><strong>Total</strong></td> | ||
<td width="9%" bgcolor="#C5DFFA"><strong>Remove</strong></td> | ||
</tr> | ||
<?php echo $cartOutput; ?> | ||
<!-- <tr> | ||
<td> </td> | ||
<td> </td> | ||
<td> </td> | ||
<td> </td> | ||
<td> </td> | ||
<td> </td> | ||
</tr> --> | ||
</table> | ||
<?php echo $cartTotal; ?> | ||
<br /> | ||
<br /> | ||
<?php echo $pp_checkout_btn; ?> | ||
<br /> | ||
<br /> | ||
<a href="cart.php?cmd=emptycart">Click Here to Empty Your Shopping Cart</a> | ||
</div> | ||
<br /> | ||
</div> | ||
<?php include_once("template_footer.php");?> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="https://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>Untitled Document</title> | ||
</head> | ||
|
||
<body> | ||
Yes this is supposed to be empty like this... happy coding. | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="https://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>Contact Page</title> | ||
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> | ||
</head> | ||
<body> | ||
<div align="center" id="mainWrapper"> | ||
<div valign="right" style="height: 300px; width: 1300px; color: #ffffff; | ||
background-image: url(style/bg1.jpg);></div> | ||
<?php include_once("template_header.php");?> | ||
<div id="pageContent"> | ||
<td width="55%" valign="top"><h1>Contact Us</h1><br/><br/> | ||
<a href="https://www.gmail.com"><h2>[email protected]</h2></a><br/> | ||
<a href="https://www.gmail.com"><h2>[email protected]</h2></a><br/><br/> | ||
</td> | ||
</div> | ||
<?php include_once("template_footer.php");?> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="https://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>Helpline Page</title> | ||
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> | ||
</head> | ||
<body> | ||
<div align="center" id="mainWrapper"> | ||
<div valign="right" style="height: 300px; width: 1300px; color: #ffffff; | ||
background-image: url(style/bg1.jpg);></div> | ||
<?php include_once("template_header.php");?> | ||
<div id="pageContent"> | ||
<td width="55%" valign="top"><h1>Our Helpline Numbers</h1><br/><br/> | ||
<h2><i>1200 0000 0000</i></h2><br/> | ||
<h2><i>1200 0000 0001</i></h2><br/><br/> | ||
</td> | ||
</div> | ||
<?php include_once("template_footer.php");?> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', '1'); | ||
?> | ||
<?php | ||
include "storescripts/connect_to_mysql.php"; | ||
$dynamicList = ""; | ||
$sql = mysqli_query($conn, "SELECT * FROM `products` ORDER BY date_added DESC LIMIT 4"); | ||
$productCount = mysqli_num_rows($sql); // count the output amount | ||
if ($productCount > 0) { | ||
while($row = mysqli_fetch_array($sql)){ | ||
$id = $row["id"]; | ||
$product_name = $row["product_name"]; | ||
$price = $row["price"]; | ||
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); | ||
$dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6"> | ||
<tr> | ||
<td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a></td> | ||
<td width="83%" valign="top">' . $product_name . '<br /> | ||
₹' . $price . '<br /> | ||
<a href="product.php?id=' . $id . '">View Product Details</a></td> | ||
</tr> | ||
</table>'; | ||
} | ||
} else { | ||
$dynamicList = "We have no products listed in our store yet"; | ||
} | ||
mysqli_close($conn); | ||
?> | ||
<!DOCTYPE> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>Store Home Page</title> | ||
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> | ||
</head> | ||
<body> | ||
<div align="center" id="mainWrapper"> | ||
<div valign="right" style="height: 300px; width: 1300px; color: #ffffff; | ||
background-image: url(style/bg1.jpg);></div> | ||
<?php include_once("template_header.php");?> | ||
<div style="height: 600px; width: 1300px; color: #ffffff; | ||
background-image: url(style/bg.jpg);> | ||
background-image: url(style/bg.jpg); | ||
<div id="pageContent"> | ||
<table width="100%" border="0" cellspacing="0" cellpadding="10"> | ||
<tr> | ||
<td width="40%" valign="top"><h2>CELEBRATE THIS SUMMER WITH OUR LATEST FASHION!!</h2> | ||
<p><h3>This is an eCommerce website with a wide range of fashionable clothing for men, women and kids at fair and reasonable prices.</h3> | ||
<p><u><b>Like us on Facebook by clicking on the link</b></u> | ||
<a href="https://www.facebook.com/">Shopnix</a> </p> | ||
<p><h2><i>The colour of this season is <font color="red">RED</font>. View our clothing range soon... </i></h2> | ||
<br /> | ||
<h1>Fill your cart NOW!!</h1></p></td> | ||
<td width="35%" valign="top"><h2>Latest Designer Fashions</h2> | ||
<p><?php echo $dynamicList; ?><br /> | ||
</p> | ||
<p><br/> | ||
</p></td> | ||
<td width="25%" valign="middle"><h1>Latest Deals..!!</h1><br/> | ||
<p><h3><i>Upto 30% off on Women Topwear<br/><br/> | ||
Upto 40% off on Men Accessories<br/><br/> | ||
Upto 45% off on Kids Bottomwear</i></h3><br/><br/> | ||
<h2>An exciting place for the whole family to shop.</h2><br/> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
<div align="center" id="mainWrapper"> | ||
<?php include_once("template_footer.php");?> | ||
</div> | ||
</body> | ||
</html> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.