Benefit PHP Shopping Cart Class (Simple Lightweight)

Overview

Benefit-PHP-Shopping-Cart-Class

Benefit PHP Shopping Cart Class (Simple Lightweight)


Table of Contents

Initialization
Get All
Get Item
Get Item Child
Get Total Sum
Get Item Sum
Total Item Count
Check Item
Check Item Child
Check Item Child Value
clear
Remove
Remove Child
Remove Child Value
Insert
Field
Update
Increment
Decrement
Put

Initialization

First you import the benefit.php file in your project

include('benefit.php');

Defining a new class

You can use the following code as an example

/* BCC = Benefit Cart Class */
$bcc = new benefit;

Get All

getAll() command pulls all products added to cart

print_r($bcc->getAll());
/* **OR** */
foreach($bcc->getAll() as $key => $value){
  /*
  * $key = ProductID, hash, crc32
  * $value = array in quantity, amount, cf (custom fields -size, color and type or gender (male, female, child))
  * Usage: $value["quantity"], $value["price"], $value["color"] (array) 
  */
}

Get Item

Bring the specified product from the basket

$bcc->fetch($item);

Get Item Child

Fetch the sub-features of the specified product from the basket

$bcc->fChild($item, $key)

Get Total Sum

Returns the total basket amount

/*
* Field (Ex): price
*/
$bcc->tPrice($field);

Get Item Sum

Returns the amount of the child product in the cart:

/*
* Ex.: $item => 7ca36866, price
*/
$bcc->tiPrice($item, $field)

Total Item Count

Returns the amount of products in the basket

$bcc->tItems();

Check Item

Checks if the product in the basket is available:

$bcc->check($item);

Check Item Child

Checks if the product in the basket has a child key

/*
* 7ca36866 in color, size or type
*/
$bcc->cChild($item, $key);

Check Item Child Value

Checks whether there is a feature or variation in the child element of the product in the basket

$bcc->cChildValue($item, $key, $value);

Clear

Clear cart

$bcc->clear();

Remove

Removes the specified product from the cart

$bcc->remove($item);

Remove Child

Removes the child element of the specified product

$bcc->rChild($item, $key);

Remove Child Value

Removes the value of the child element of the specified product

$bcc->rChildValue($item, $key, $value);

Insert

Adds the product to the basket

/*
* The default quantity is 1
* Specify variation with field before using insert function
*/
$bcc->insert($item, $quantity);

Field

Variation for the product to be added can be identified

field($item, $cf); ">
/*
* $cf is array()
* Ex:
* $data = ["color" = ["red", "green", "blue"], "size" = ["s", "m", "l", "xl"]]
*/
$bcc->field($item, $cf);

Update

Updates the key value specified in the product

$bcc->update($item, $key, $value);

Increment

Increases the amount of the specified key

$bcc->inc($item);

Decrement

Decreases the amount of the specified key

$bcc->dec($item);

Put

Records the finished operations

/*
* You usually don't need to use this command
*/
$bcc->put();
You might also like...
Topshop offers its customers a modern shopping experience by bringing computers, appliances, clothing and many other items at their fingertips.
Topshop offers its customers a modern shopping experience by bringing computers, appliances, clothing and many other items at their fingertips.

Topshop offers its customers a modern shopping experience by bringing computers, appliances, clothing and many other items at their fingertips. With just a few clicks, users can create an account, add products to their cart and place their order.

Magento 2 module to only allow checkout when the number of items in the cart are a multiple of X.

Cart Quantity Multiple - Magento 2 Module Introduction This module allows to limit checkout only when the contents of the cart are a multiple of X

Zen Cart® is a full-function e-commerce application for your website.
Zen Cart® is a full-function e-commerce application for your website.

Zen Cart® - The Art of E-Commerce Zen Cart® was the first Open Source e-Commerce web application to be fully PA-DSS Certified. Zen Cart® v1.5.8 is an

(Live Link) Extensive ecommerce site with vendors, mods & ability to add to cart without being logged in. Upgraded to Laravel 8.x
(Live Link) Extensive ecommerce site with vendors, mods & ability to add to cart without being logged in. Upgraded to Laravel 8.x

(Live Link) Extensive ecommerce site with vendors, mods & ability to add to cart without being logged in. Upgraded to Laravel 8.x

Magento 2 Share Cart extension Free
Magento 2 Share Cart extension Free

Mageplaza Share Cart Extension helps customers in sharing their shopping cart with friends and family as well. This is a supportive method to promote store’s conversion rate via the existing users, and this can significantly contribute to the revenue of the store.

Simple E-Comerce build use Laravel 5.6 require php version 5.6 or 7.4

Simple E-Comerce build use Laravel 5.6 require php version 5.6 or 7.4

A simple shoppingcart implementation for Phalcon.

Phalcon Shopping Cart A simple shoppingcart implementation for Phalcon. Installation Install the package through Composer. Run the Composer require co

Simple Ecommerce Platform on Symfony - E-Learning

Simple Ecommerce Platform on Symfony - E-Learning

Build a simple ecommerce website with Laravel.

Simple Ecommerce Build a simple ecommerce website with Laravel. Explore the docs » View Demo · Report Bug · Request Feature Table of Contents Getting

Owner
Osman Cakmak
Back-End Developer
Osman Cakmak
A simple shopping cart implementation for Laravel

LaravelShoppingcart This is a fork of Crinsane's LaravelShoppingcart extended with minor features compatible with Laravel 8+. An example integration c

Patrick 453 Jan 2, 2023
LiteCart - Free Shopping Cart Platform - Built with PHP, jQuery HTML 5 and CSS 3

LiteCart is a lightweight e-commerce platform for online merchants. Developed in PHP, HTML 5, and CSS 3. LiteCart is a registered trademark, property

LiteCart 153 Dec 28, 2022
A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.

OpenCart is a free open source ecommerce platform for online merchants. OpenCart provides a professional and reliable foundation from which to build a successful online store.

OpenCart 6.6k Dec 31, 2022
AvoRed an Open Source Laravel Shopping Cart

AvoRed is commin up as a headless graphql version. AvoRed is a free open-source e-commerce platform written in PHP based on Laravel. Its an ingenuous

AvoRed Laravel E commerce 1.4k Dec 30, 2022
Laravel Shopping Cart Package

LaraCart - Laravel Shopping Cart Package (http://laracart.lukepolo.com) Features Coupons Session Based System Cross Device Support Multiple cart insta

Luke Policinski 516 Dec 10, 2022
AvoRed an Open Source Laravel Shopping Cart

AvoRed is commin up as a headless graphql version. AvoRed is a free open-source e-commerce platform written in PHP based on Laravel. Its an ingenuous

AvoRed Laravel E commerce 1.4k Dec 28, 2022
Shopping Cart Implementation for Laravel Framework

Shopping Cart Implementation for Laravel Framework

darryl fernandez 1.2k Jan 4, 2023
PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

PrestaShop is an Open Source e-commerce web application, committed to providing the best shopping cart experience for both merchants and customers. It is written in PHP, is highly customizable, supports all the major payment services, is translated in many languages and localized for many countries, has a fully responsive design (both front and back office), etc. See all the available features.

PrestaShop 6.9k Dec 31, 2022
The Online Shopping System in PHP using XAMPP as virtual Server.

Online shopping is a form of electronic commerce which allows consumers to directly buy goods or services from a seller over the Internet using a web browser or a mobile app.

Magesh Surya Ambikapathi 5 Sep 15, 2022
A robust session-based shopping bag for Laravel

Shopping Bag A robust session-based shopping bag for Laravel Go to documentation Documentation Documentation for Shopping Bag can be found in the docs

Laraware 30 Dec 13, 2021