stnc/shopping-cart

php shopping cart class

2.1.4 2020-08-27 21:36 UTC

This package is auto-updated.

Last update: 2024-04-28 06:22:21 UTC


README

php simple shopping cart class and html ajax example

Install

composer require stnc/shopping-cart

SCREENSHOT

screen2.png

screen.png

init

       
        // 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 function

add to cart

$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 function

cart to remove

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

getJson function

cart json info

   $cart->getJson();

viewCart function

emptyCart function

cart empty

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

getArray function

cart to result array

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

cartCount fonksiyonu

gives information about the total of items in the basket

	  print_r($cart->cartCount());

cartInfo fonksiyonu

Cart information

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