<?php
session_start();
$starttime = microtime();
$startarray = explode(" ", $starttime);
$starttime = $startarray[1] + $startarray[0];
$self = $_SERVER['PHP_SELF'];
$PAYMENT_GATEWAY=$self;]
//data file
$fl=’cart-data.txt’;
//add to cart action
$page_name=’one-page-ecommerce-cart-cms.php’;
//set file product fields array
$fields=array(
‘id’,
‘product_code’,
‘product_name’,
‘product_desc’,
‘product_img’,
‘price’,
‘weight’,
‘catalog’,
‘catid’,
);
$taxout=”;
$shipout=”;
//gateway and other form variables
$tax_rate=’6′;
$taxstate=’WV’;
$currency=’USD’;
//base handling added to ship percentage
$handling=’5′;
$ship_rate=’10’;
//$price=’amount’;
//$name=’item_name’;
//$num=’item_num’;
//$desc=’item_desc’;
function flock_utf8_contents($filename){
$return = FALSE;
if(file_exists($filename) and is_readable($filename)){
if($handle = @fopen($filename, ‘r’)){
while(!$return){
if(flock($handle, LOCK_SH)){
if($return = file_get_contents($filename)){
flock($handle, LOCK_UN);
}}}fclose($handle);}}
return mb_convert_encoding($return, ‘UTF-8’,
mb_detect_encoding($return, ‘UTF-8, ISO-8859-1’, true));}
$str=flock_utf8_contents($fl);
function parse_file() {
global $str;
global $fields;
$res=array();
$lines=array();
$output = array();
$output = explode("\n", $str);
$output=array_filter($output);
$output=array_map(‘trim’, $output);
foreach ($output as $key=>$data) {
$lines = explode(‘;’, $data);
$res[]=array_combine($fields,$lines);
}
return $res;
}
$current_url = base64_encode("http://".$_SERVER[object 4].$_SERVER['REQUEST_URI']);
$res=parse_file();
function find($string, $array){
foreach ($array as $key => $value) {
unset ($array[$key]);
if (in_array($string, $value)) {
$array[$key] = $value;}}
return $array;}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>php simple ecommerce cms with shopping cart just one page of code remarkable and free <?php echo $title;?></title>
<meta name="description" content="Free php flatfile database ecommerce and shopping cart script. A complete ecommerce shop and cart all on just one page of code. Easy to set up checkout form to post to google paypal or your gateway. Can modify for you as well. Another great cmxtendable script from handicapped george.">
<meta name="robots" content="index">
<style type="text/css">
body, html {
margin-top:10px;
font-size:14px;
height:100%;
min-height:100%;
font-family: Tahoma, Arial;
background:#E0E0E0;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#E0E0E0 ));*/
background: -moz-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
background: -o-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
background: linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
}
#wrapper {
padding:20px;
width:750px;
margin: auto;
min-height:100%;
background-color: #ffffff;
border: 2px solid #333;
/* curved border radius */
-moz-border-radius:20px;
-webkit-border-radius:20px;
-o-border-radius:20px;
border-radius:20px;
}
.box{
display: none;
width: 100%;
}
a:hover + .box,.box:hover{
display: block;
position: relative;
z-index: 100;
}
</style>
</head>
<body>
![]() |
ShoppingFlatfile Ecommerce CMXtendable Shopping Cart all in just one page of code. |
<br>
echo ‘
echo “”;
echo ‘
‘;
echo ‘
‘.$val[“product_name”].’
‘;
echo ‘
‘;
echo ‘
‘;
//echo ‘<input type="text" name="product_qty" value="1" />’;
echo ‘</div>’;
echo ‘<input type="hidden" name="product_code" value="’.$val["product_code"].’">’;
echo ‘<input type="hidden" name="type" value="add" />’;
echo ‘<input type="hidden" name="return_url" value="’.$current_url.’">’;
echo ‘</form>’;
echo ‘</div>’;
}
?>
</div>
‘;
$total = 0;
echo “”;
echo ‘
- ‘;
- ‘;
if(empty($cart_itm['qty'])){
$cart_itm['qty']=’1’;
}
echo ‘‘;
echo ‘‘.$rs['product_name'].’ (Item # :’.$rs['product_code'].’) ‘;
echo ‘Qty : ‘.$cart_itm['qty'].’‘;
echo ‘‘.$rs['product_desc'].’‘;
echo ‘‘.$currency.$rs['price'].’‘;
echo ‘</div>’;
echo ‘<span style="background:crimson;padding-right:5px;padding-left:5px;text-align:center;"><a style="text-decoration:none;font-weight:bold;color:white;text-align:center;" href="’.$page_name.’?removep=’.$cart_itm["code"].’&return_url=’.$current_url.’">× Delete</a></span>’;
echo ‘</li>’;
$subtotal = ($cart_itm['price']*$cart_itm['qty']);
$total = ($total + $subtotal);
echo ‘<input type="hidden" name="item_name['.$cart_items.']" value="’.$rs['product_name'].’" />’;
echo ‘<input type="hidden" name="item_code['.$cart_items.']" value="’.$rs['product_code'].’" />’;
echo ‘<input type="hidden" name="item_desc['.$cart_items.']" value="’.$rs['product_desc'].’" />’;
echo ‘<input type="hidden" name="item_qty['.$cart_items.']" value="’.$cart_itm["qty"].’" />’;$cart_items ++;
}}
echo ‘</ul>’;
echo ‘<span class="check-out-txt">’;
if($tax_rate){
$tax = $total * $tax_rate / 100;
$tax=substr($tax,0,-1);
$total=$total+$tax;
$taxout= "$taxstate tax: $tax_rate% $tax";
}
if($ship_rate){
$shipping = $total * $ship_rate / 100;
$shipping =$shipping+ $handling;
$shipout= ‘shipping ‘.$currency.number_format($shipping,2);
$total=$total+$tax+$shipping;
}
echo ‘<strong>’.$shipout.'<br>Total. : ‘.$currency.number_format($total,2).’ – ‘.$taxout.'</strong>’;
echo ‘</span>’;
if($subtotal>=0){
echo ‘<br><br><input type="submit" name="type" value="Begin Checkout">’;
}
echo ‘</form>’;
}else{
echo ‘<strong>Cart is empty add something.</strong>’;
}
?>
</div>
<?php
if(isset($_GET["emptycart"]) && $_GET["emptycart"]==1){
$return_url = base64_decode($_GET["return_url"]);
session_destroy();
// header(‘Location:’.$return_url);
echo "<meta http-equiv=\"Refresh\" content=\"0;URL=$return_url\">";
}if(isset($_POST["type"]) && $_POST["type"]==’add’){
$product_code = filter_var($_POST["product_code"], FILTER_SANITIZE_STRING);
$product_qty = filter_var($_POST["product_qty"], FILTER_SANITIZE_NUMBER_INT);
$return_url = base64_decode($_POST["return_url"]); //return urlif($product_qty > 10){
die("Maximum quantity of 10 reached.");
}$res=parse_file();
for($i=0; $i<count($res); $i++){
$results = find ($product_code, $res);
}
if ($results) {
foreach ($results as $key=>$rs) {
$new_product = array(array(‘name’=>$rs['product_name'], ‘code’=>$rs['product_code'], ‘qty’=>$cart_itm["qty"], ‘price’=>$rs['price']));if(isset($_SESSION["products"])){
$found = false;
foreach ($_SESSION["products"] as $cart_itm){
if($cart_itm["code"] == $product_code){
$product[] = array(‘name’=>$cart_itm["name"], ‘code’=>$cart_itm["code"], ‘qty’=>$product_qty, ‘price’=>$cart_itm["price"]);
$found = true;
}else{
$product[] = array(‘name’=>$cart_itm["name"], ‘code’=>$cart_itm["code"], ‘qty’=>$cart_itm["qty"], ‘price’=>$cart_itm["price"]);
}
}
if($found == false) {
$_SESSION["products"] = array_merge($product, $new_product);
}else{
$_SESSION["products"] = $product;
}
}else{
$_SESSION["products"] = $new_product;
}
}
}
// header(‘Location:’.$return_url);
echo "<meta http-equiv=\"Refresh\" content=\"0;URL=$return_url\">";
}
if(isset($_GET["removep"]) && isset($_GET["return_url"]) && isset($_SESSION["products"])){
$product_code = $_GET["removep"]; //get the product code to remove
$return_url = base64_decode($_GET["return_url"]); //get return urlforeach ($_SESSION["products"] as $cart_itm){
if($cart_itm["code"]!=$product_code){
$product[] = array(‘name’=>$cart_itm["name"], ‘code’=>$cart_itm["code"], ‘qty’=>$cart_itm["qty"], ‘price’=>$cart_itm["price"]);
}
$_SESSION["products"] = $product;
}
// header(‘Location:’.$return_url);
echo "<meta http-equiv=\"Refresh\" content=\"0;URL=$return_url\">";
}echo "
";
$endtime = microtime();
$endarray = explode(" ", $endtime);
$endtime = $endarray[1] + $endarray[0];
$totaltime = $endtime – $starttime;
$totaltime = round($totaltime,4);
echo "
This search took $totaltime seconds to complete.”;
function convert($size)
{
$unit=array(‘b’,’kb’,’mb’,’gb’,’tb’,’pb’);
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).’ ‘.$unit[$i];
}echo ‘ Memory usage ‘ . convert(memory_get_usage(true)) . ‘
‘; // 123 kb
echo ‘</div>’;
echo ‘<p style="width:100%;text-align:center;"><a href="http://www.cmxads.com/one-page-ecommerce-cms.php">Cmxads.com One Page Ecommerce CMS Php Script</a></p>’;
echo ‘</body>’;
echo ‘</html>’;
?>Mahalo
SIGNATURE:
Clifford "RAY" Hackett www.rayis.me RESUME: www.rayis.me/resumeI founded www.adapt.org in 1980 it now has over 50 million members.
$500 of material=World’s fastest hydrofoil sailboat. http://sunrun.biz
$cart_items = 0;
foreach ($_SESSION[“products”] as $cart_itm)
{
$product_code = $cart_itm[“code”];
$res=parse_file();
for($i=0; $i$rs) {
echo ‘
