PHP Class EShoppingCart

Author: pirrat ([email protected])
Inheritance: extends CMap
Mostra file Open project: yupe/yupe Class Usage Examples

Public Properties

Property Type Description
$cartId string
$discounts array
$refresh boolean Update the model on session restore?

Protected Properties

Property Type Description
$couponManager CouponManager
$discountPrice float Cart-wide discount sum
$eventManager yupe\components\EventManager

Public Methods

Method Description
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.

Protected Methods

Method Description
applyDiscounts ( ) : void Apply discounts to all positions
saveState ( ) : void Saves the state of the object in the session.

Method Details

add() public method

Add $value items to position with $key specified
public add ( mixed $key, mixed $value ) : void
$key mixed
$value mixed
return void

addDiscountPrice() public method

Add $price to cart-wide discount sum
public addDiscountPrice ( float $price ) : void
$price float
return void

applyDiscounts() protected method

Apply discounts to all positions
protected applyDiscounts ( ) : void
return void

getCost() public method

Returns total price for all items in the shopping cart.
public getCost ( boolean $withDiscount = true ) : float
$withDiscount boolean
return float

getCouponManager() public method

public getCouponManager ( ) : CouponManager
return CouponManager

getItemsCount() public method

Returns count of items in shopping cart
public getItemsCount ( ) : integer
return integer

getPositions() public method

Returns array all positions
public getPositions ( ) : array
return array

init() public method

public init ( )

isEmpty() public method

Returns if cart is empty
public isEmpty ( ) : boolean
return boolean

put() public method

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() public method

Removes position from the shopping cart of key
public remove ( mixed $key ) : mixed | void
$key mixed
return mixed | void

restoreFromSession() public method

Restores the shopping cart from the session
public restoreFromSession ( )

saveState() protected method

Saves the state of the object in the session.
protected saveState ( ) : void
return void

setDiscountPrice() public method

Set cart-wide discount sum
public setDiscountPrice ( float $price ) : void
$price float
return void

update() public method

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

Property Details

$cartId public_oe property

public string $cartId
return string

$couponManager protected_oe property

protected CouponManager $couponManager
return CouponManager

$discountPrice protected_oe property

Cart-wide discount sum
protected float $discountPrice
return float

$discounts public_oe property

public array $discounts
return array

$eventManager protected_oe property

protected EventManager,yupe\components $eventManager
return yupe\components\EventManager

$refresh public_oe property

Update the model on session restore?
public bool $refresh
return boolean