PHP Класс EShoppingCart

Автор: pirrat ([email protected])
Наследование: extends CMap
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$cartId string
$discounts array
$refresh boolean Update the model on session restore?

Защищенные свойства (Protected)

Свойство Тип Описание
$couponManager CouponManager
$discountPrice float Cart-wide discount sum
$eventManager yupe\components\EventManager

Открытые методы

Метод Описание
add ( mixed $key, mixed $value ) : void Add $value items to position with $key specified
addDiscountPrice ( float $price ) : void Add $price to cart-wide discount sum
getCost ( boolean $withDiscount = true ) : float Returns total price for all items in the shopping cart.
getCouponManager ( ) : CouponManager
getItemsCount ( ) : integer Returns count of items in shopping cart
getPositions ( ) : array Returns array all positions
init ( )
isEmpty ( ) : boolean Returns if cart is empty
put ( IECartPosition $position, $quantity = 1 ) Add item to the shopping cart If the position was previously added to the cart, then information about it is updated, and count increases by $quantity
remove ( mixed $key ) : mixed | void Removes position from the shopping cart of key
restoreFromSession ( ) Restores the shopping cart from the session
setDiscountPrice ( float $price ) : void Set cart-wide discount sum
update ( IECartPosition $position, integer $quantity ) Updates the position in the shopping cart If position was previously added, then it will be updated in shopping cart, if position was not previously in the cart, it will be added there.

Защищенные методы

Метод Описание
applyDiscounts ( ) : void Apply discounts to all positions
saveState ( ) : void Saves the state of the object in the session.

Описание методов

add() публичный Метод

Add $value items to position with $key specified
public add ( mixed $key, mixed $value ) : void
$key mixed
$value mixed
Результат void

addDiscountPrice() публичный Метод

Add $price to cart-wide discount sum
public addDiscountPrice ( float $price ) : void
$price float
Результат void

applyDiscounts() защищенный Метод

Apply discounts to all positions
protected applyDiscounts ( ) : void
Результат void

getCost() публичный Метод

Returns total price for all items in the shopping cart.
public getCost ( boolean $withDiscount = true ) : float
$withDiscount boolean
Результат float

getCouponManager() публичный Метод

public getCouponManager ( ) : CouponManager
Результат CouponManager

getItemsCount() публичный Метод

Returns count of items in shopping cart
public getItemsCount ( ) : integer
Результат integer

getPositions() публичный Метод

Returns array all positions
public getPositions ( ) : array
Результат array

init() публичный Метод

public init ( )

isEmpty() публичный Метод

Returns if cart is empty
public isEmpty ( ) : boolean
Результат boolean

put() публичный Метод

Add item to the shopping cart If the position was previously added to the cart, then information about it is updated, and count increases by $quantity
public put ( IECartPosition $position, $quantity = 1 )
$position IECartPosition

remove() публичный Метод

Removes position from the shopping cart of key
public remove ( mixed $key ) : mixed | void
$key mixed
Результат mixed | void

restoreFromSession() публичный Метод

Restores the shopping cart from the session
public restoreFromSession ( )

saveState() защищенный Метод

Saves the state of the object in the session.
protected saveState ( ) : void
Результат void

setDiscountPrice() публичный Метод

Set cart-wide discount sum
public setDiscountPrice ( float $price ) : void
$price float
Результат void

update() публичный Метод

If count is less than 1, the position will be deleted.
public update ( IECartPosition $position, integer $quantity )
$position IECartPosition
$quantity integer

Описание свойств

$cartId публичное свойство

public string $cartId
Результат string

$couponManager защищенное свойство

protected CouponManager $couponManager
Результат CouponManager

$discountPrice защищенное свойство

Cart-wide discount sum
protected float $discountPrice
Результат float

$discounts публичное свойство

public array $discounts
Результат array

$eventManager защищенное свойство

protected EventManager,yupe\components $eventManager
Результат yupe\components\EventManager

$refresh публичное свойство

Update the model on session restore?
public bool $refresh
Результат boolean