<?php class Cart { //物品id及名称规则,调试信息控制 private $product_id_rule = '\.a-z0-9-_'; //小写字母 | 数字 | ._- private $product_name_rule = '\.\:a-z0-9-_';//小写字母 | 数字 | ._-: private $debug = TRUE; private $_cart_contents = array(); public function __construct() { //是否第一次使用? if(isset($_SESSION['cart_contents'])) { $this->_cart_contents = $_SESSION['cart_contents']; } else { $this->_cart_contents['cart_total'] = 0; $this->_cart_contents['total_items'] = 0; } if($this->debug === TRUE) { //$this->_log("cart_create_success"); } }
PHP's shopping cart class library mainly introduces the shopping cart class implemented by PHP, which can realize basic adding, deleting, statistics and other related functions of the shopping cart.
The basic functions of the shopping cart are as follows: 1) Add items Shopping cart 2) Delete items from the shopping cart 3) Update shopping cart item information [1/-1] 4) Statistics of shopping cart items 1. Total items 2. Total quantity 3. Total amount 5) Statistics of single shopping items Statistics of quantity and amount 6) Clear shopping
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
29Jul2016
php shopping cart: php shopping cart php shopping cart implementation code: ShopCar.php Copy the code as follows:
13Jul2016
PHP simple shopping cart design. In this program, two classes are created, one is the general Product class, which encapsulates a product and product attributes, and the other is the Cart class of the shopping cart. Product class (Product.php) product
19Jun2018
This article introduces a shopping cart code implemented in PHP. The function implementation is relatively complete. It implements shopping cart, orderer information, membership price and other functions. It is still good. Friends in need can refer to it.
13Jul2016
PHP shopping cart implementation method, PHP shopping cart implementation. PHP shopping cart implementation method, PHP shopping cart implementation This article describes the PHP shopping cart implementation method with examples. Share it with everyone for your reference. The specific analysis is as follows: Here we provide you with a simple
13Jul2016
PHP shopping cart usage to update the shopping cart quantity. The number of shopping carts means that when we buy something, we can delete and add items at any time. In this way, our shopping cart must update the record. Let me introduce to you PHP shopping cart update purchase.
01Sep2020
How to implement the php shopping cart function: first log in to the website to browse the products; then purchase the specified products; then enter the shopping cart page, where you can change the number of products, delete products, clear the shopping cart, continue shopping, etc.; and finally implement Just generate an order, submit the order and other operations.
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images