PHP Class EShoppingCart

Author: pirrat ([email protected])
Inheritance: extends CMap
Afficher le fichier Open project: yupe/yupe Class Usage Examples

Méthodes publiques

Свойство Type Description
$cartId string
$discounts array
$refresh boolean Update the model on session restore?

Protected Properties

Свойство Type Description
$couponManager CouponManager
$discountPrice float Cart-wide discount sum
$eventManager yupe\components\EventManager

Méthodes publiques

Méthode 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.

Méthodes protégées

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

Method Details

add() public méthode

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

addDiscountPrice() public méthode

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

applyDiscounts() protected méthode

Apply discounts to all positions
protected applyDiscounts ( ) : void
Résultat void

getCost() public méthode

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

getCouponManager() public méthode

public getCouponManager ( ) : CouponManager
Résultat CouponManager

getItemsCount() public méthode

Returns count of items in shopping cart
public getItemsCount ( ) : integer
Résultat integer

getPositions() public méthode

Returns array all positions
public getPositions ( ) : array
Résultat array

init() public méthode

public init ( )

isEmpty() public méthode

Returns if cart is empty
public isEmpty ( ) : boolean
Résultat boolean

put() public méthode

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 méthode

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

restoreFromSession() public méthode

Restores the shopping cart from the session
public restoreFromSession ( )

saveState() protected méthode

Saves the state of the object in the session.
protected saveState ( ) : void
Résultat void

setDiscountPrice() public méthode

Set cart-wide discount sum
public setDiscountPrice ( float $price ) : void
$price float
Résultat void

update() public méthode

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
Résultat string

$couponManager protected_oe property

protected CouponManager $couponManager
Résultat CouponManager

$discountPrice protected_oe property

Cart-wide discount sum
protected float $discountPrice
Résultat float

$discounts public_oe property

public array $discounts
Résultat array

$eventManager protected_oe property

protected EventManager,yupe\components $eventManager
Résultat yupe\components\EventManager

$refresh public_oe property

Update the model on session restore?
public bool $refresh
Résultat boolean