stnc/shopping-cart

PHP 购物车类

2.1.4 2020-08-27 21:36 UTC

This package is auto-updated.

Last update: 2024-09-28 07:19:25 UTC


README

PHP 简单购物车类和 HTML AJAX 示例

安装

composer require stnc/shopping-cart

屏幕截图

初始化

       
        // use use \Stnc\ShoppingCart\Cart;
$cart_name = 'stnc'; // sepetin session değerine bir değer atadık
$cart = new Cart($cart_name);
$cart->groups=false;

ADDTOCART 函数

添加到购物车

$data = array(
		'productID' => 100,
		'productName' => "ice cream",
		'productImageURL' => "https://example.org/icecream.jpg",
		'URL' => "https://example.org/product/100",
		'price' => 40.99,
		"totalEach" => 1,
		'stockUnit'=>'unit',
		"totalPrice" => 40.99
);
$cart->addToCart("100", $data);
	  echo '<pre>';
	  print_r($cart->getArray());
	  echo '</pre>';

removeCart 函数

从购物车中移除

   $cart->removeCart(100);
	  echo '<pre>';
	  print_r($cart->getArray());
	  echo '</pre>';

getJson 函数

购物车 JSON 信息

   $cart->getJson();

viewCart 函数

emptyCart 函数

购物车清空

   $cart->emptyCart();
 	  echo '<pre>';
	  print_r($cart->getArray());
	  echo '</pre>';

getArray 函数

购物车到结果数组

	  echo '<pre>';
	  print_r($cart->getArray());
	  echo '</pre>';
// 
 print_r( $cart->cartCount());

cartCount 函数

提供有关篮中物品总数的详细信息

	  print_r($cart->cartCount());

cartInfo 函数

购物车信息

	  print_r($cart->cartInfo());
demo page thx 
https://startbootstrap.com/templates/heroic-features/