PHP open-source shopping cart Magento Community Edition 1.7 is released. Magento is a professional open-source PHP e-commerce system. Magento is designed flexibly and has a modular architecture and rich functions. It is easy to seamlessly integrate with third-party application systems. Magento is a professional open-so
Php shopping cart implementation code and application example
Class Shopcar
{
// Product list
Public $ productList = array ();
/**
*
* @ Param unknown_type $ the product to be imported
* @ Return true no such item exists in the shopping
First, determine if you are logged in,if (Isset ($_session[' user_id ')) {ExistAdd the user ID and product ID to the shopping cart table}else{Do not exist; Use cookies to put the commodity ID and host IP into an array, the array is stored in a cookie, and the browser is allowed to store 300 cookies,Each cookie is 4KB large enough to meet the requirements of the shopping
Simple idea, really shopping cart far more complex than this, suitable for beginners, easy to understand$result _arr = Here is the query result, or data, or string;Analog data: Array ([0] = = Array ([id] = = 40920435 [title] = 42432 [Addtime] = 2018-02-08 09:22:37 [content] = 432432 [PHOTO] = 2018-02-08/5a7ba65d89746.jpg))$result = Serialize ($result _arr); Array must be serializedAfter serialization: A:1:{
This article describes the implementation of a more comprehensive PHP shopping cart class. Share to everyone for your reference. The implementation methods are as follows:
To do a project a long time ago, you need to use a shopping cart, considering that it may be used freq
Example 1
Recently in writing ANE-commerce website, in the shopping cart when found in PHP does not have a map of this data structure, we can not simply through a hashmap to implement the shopping cart, so I think of the array, through the format of the value of the array t
This article mainly introduces how to add Chinese characters to the Codeigniter shopping cart class, which involves the restriction on Chinese characters in the underlying code. You can modify the regular expression matching rules to solve the problem, for more information about how to add Chinese characters to the Codeigniter shopping
Class Shopcar
{
Product List
Public $productList =array ();
/**
*
* @param unknown_type $product in the product
* @return True there is no item in the cart
*/
Public Function checkproduct ($product)
{
for ($i =0; $i
productlist); $i + +)
{
if ($this->productlist[$i] [' name ']== $product [' name '])
return $i;
}
return-1;
}
Add to
= mysql_num_rows ($ result );
Return $ num_rows;
}
Function quant_items ($ table, $ session ){
$ Quant = 0;
$ Query = "SELECT * FROM $ table WHERE session = '$ session '";
$ Result = mysql_query ($ query );
While ($ row = mysql_fetch_object ($ result )){
$ Quant + = $ row-> quantity;
}
Return $ quant;
}
}
?>
/*
This part contains a description of how to create the tables on your mysql server.
# MySQL dump 6.0
#
# Host: localhost Database: kmartShopper
#---------------------------------------
Code for the PHP shopping cartPublished by: [Longlong16] Time: [2006-11-1]? if (! $session ! $scid) { $session = MD5 (Uniqid (rand ()); Setcookie (SCID, $session, Time () + 14400); }/* Last number are expiration time in seconds, 14400 sec = 4 hrs * * Class Cart { function Check_item ($table, $session, $product) { $query = SELECT * from $table WHERE session= ' $
PHP e-commerce shopping cart ——— Package database operation class
After the database is established, we still encapsulate a database of Operation class Bar (refer to the Mypdo written by the teacher, after the article appended a PDO summary in the Learning Summary module).
if (file_exists (_dir_. ') Db.ini ') {$ini = Parse_ini_file (' Db.i
Shopping cart cookies are stored for 1 days. Note: Browsers must support cookies to be able to use them. This article mainly and everyone introduced in detail the PHP implementation of the storage cycle for 1 days shopping cart category, with a certain reference value, inter
This article is mainly for everyone to introduce the PHP implementation of the storage cycle for 1 days of shopping cart class, with a certain reference value, interested in small partners can refer to
Shopping cart cookies are stored for 1 days. Note: Browsers must support
The code is as follows:Copy code Class Shopcar{// Product listPublic $ productList = array ();/*** * @ Param unknown_type $ the product to be imported* @ Return true no such item exists in the shopping cart*/Public function checkProduct ($ product){For ($ I = 0; $ I {If ($ this-> productList [$ I] ['name'] = $ product ['name'])Return $ I;}Return-1;}// Add to
ShopCar. phpCopy codeThe Code is as follows:Class Shopcar{// Product listPublic $ productList = array ();/**** @ Param unknown_type $ the product to be imported* @ Return true no such item exists in the shopping cart*/Public function checkProduct ($ product){For ($ I = 0; $ I {If ($ this-> productList [$ I] ['name'] = $ product ['name'])Return $ I;}Return-1;}// Add to s
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.