PHP code example of houdunwang / cart

1. Go to this page and download the library: Download houdunwang/cart library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

houdunwang / cart example snippets


$data = [ 
	'id' 		=> 1, // 商品 ID 
	'name'		=>' 后盾网 PHP 视频教程光盘 ',// 商品名称 
	'num' 		=> 2, // 商品数量 
	'price' 	=> 988, // 商品价格 
	'options'   => [],// 其他参数如价格、颜色、可以为数组或字符串 
	'color' 	=> 'red', 
	'size' 	    => 'L' 
]; 
Cart::add($data);

$data=array( 
	'sid'=>'商品唯一编号',// 唯一 sid,添加购物车时自动生成 
	'num'=>88 
); 
Cart::update($data); 

echo Cart::getTotalPrice();