Home PHP Libraries Other libraries PHP shopping cart library
PHP shopping cart library
<?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

Disclaimer

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

php shopping cart php shopping cart implementation code php shopping cart php shopping cart implementation code

29 Jul 2016

php shopping cart: php shopping cart php shopping cart implementation code: ShopCar.php Copy the code as follows: <?php class Shopcar { //Product list public $productList=array(); /** * * @param unknown_type $product Pass Incoming products* @return true There is no such product in the shopping cart*/ public function checkProduct($product) { for

PHP simple shopping cart class design_PHP tutorial PHP simple shopping cart class design_PHP tutorial

13 Jul 2016

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

Code 1 about implementing shopping cart in php Code 1 about implementing shopping cart in php

19 Jun 2018

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.

PHP shopping cart implementation method, PHP shopping cart implementation_PHP tutorial PHP shopping cart implementation method, PHP shopping cart implementation_PHP tutorial

13 Jul 2016

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

PHP Shopping Cart Usage: Update Shopping Cart Quantity_PHP Tutorial PHP Shopping Cart Usage: Update Shopping Cart Quantity_PHP Tutorial

13 Jul 2016

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.

How to implement the php shopping cart function How to implement the php shopping cart function

01 Sep 2020

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.

See all articles