Cart Library



( ZN >= 0.0.1 )

It is a library that contains a set of functions such as adding a sought-after basket for e-commerce sites, and exiting from the basket. Uses 2 drives.

 

# Configuration


File: Config / Storage.php
String $ driver = 'session' One of the available baskets. Predefined session is used to store data.
Options session , cookie

 

# Methods


Bool insertItem / insert ( Array $ product )
Array selectItems / selectAll ( Void )
Object selectItem / select ( Mixed $ code )
Int totalItems ( Void )
Int totalPrices ( Void )
Bool updateItem / update ( Mixed $ code , Array $ data )
Bool deleteItem / delete ( Mixed $ code )
Bool deleteItems / deleteAll ( Void )

 

# InsertItem / Insert ( ZN> = 0.0.1 )


Sepete is used to add products.

Parameters

Array $ product Products range. Products have to accommodate the price and quantity values ​​of the series .
price The product should keep the price information.
quantity The product should keep track of quantity. If this value is not specified in the stringquantityvalue 1 is accepted.
return Bool

uses

Cart::insertItem
([
    'product'       => 'Banana',
    'price'         => '10',
    'quantity'      => 3,
    'serial-number' => '4432222345219'
]);

 

# SelectItems / SelectAll ( ZN >= 0.0.1 )


Sepete gives the type of products added in the array type.

Parameters

void
return Array

uses

output( Cart::selectItems() );
0 => array
(
        product        => string 'Banana' (length = 8 ) ,
        price          => string '10' (length = 4 ) ,
        quantity       => integer 3 (length = 1 ) ,
        serial-number => string '4432222345219 ' (length = 15 ) ,
)

 

# SelectItem / Select ( ZN >= 0.0.1 )


Used to make selections from the added products. The parameter can take values ​​in both string and array types.

Parameters

Mixed $ Code The code of the product to be selected. This code can be any of the product's data.
return Object

uses

Any of the product information can be used to select the product. For example, it is right to use the most discriminating knowledge to capture the name, the name but the right product .

$product = Cart::selectItem('4432222345219');

\Output::writeLine( $product->product );
\Output::writeLine( $product->price );
Banana
10

Array Submission

You can select from the array using the array .

output( Cart::selectItem(['product' => 'Banana']) );
product        => string 'Banana' (length = 8 ) ,
price          => string '10' (length = 4 ) ,
quantity       => integer 3 (length = 1 ) ,
serial-number => string '4432222345219' (length = 15 )

 

# TotalItems ( ZN >= 0.0.1 )


It gives the total number of products in the basket.

Parameters

void
return Int

uses

echo Cart::totalItems();
3

 

# TotalPrices ( ZN >= 0.0.1 )


It gives the total price of products in the basket.

Parameters

void
return Int

uses

echo Cart::totalPrices();
30

 

# UpdateItem / Update ( ZN >= 0.0.1 )


Used to update the product in the cart. It selectItem()is the same as the parameter usage method.

Parameters

Mixed $ Code The code of the product to be selected. This code can be any of the product's data.
Array $ product Products range.
return Bool

uses

Cart::updateItem('Banana', ['product' => 'Orange']);
output( Cart::selectItem('Orange') );
product        => string 'Orange' (length = 8 ) ,
price          => string '10' (length = 3 ) ,
quantity       => integer 3 (length = 1 ) ,
serial-number => string '4432222345219' (length = 15 )

 

# DeleteItem / Delete ( ZN> = 0.0.1 )

Used to clean the product in the basket. The use of the parameter is the same as the selectItem () method.

Parameters

Mixed $ Code The code of the product to be selected. This code can be any of the product's data.
return Bool

uses

Cart::deleteItem('Orange');

 

# DeleteItems / DeleteAll ( ZN> = 0.0.1 )


It is used to delete all products in the cart.

Parameters

void
return Bool

uses

Cart::deleteItems();