PHP 클래스 ShoppingCart, silvershop-core

Ensures that an order is only started (persisted to DB) when necessary, and all future changes are on the same order, until the order has is placed. The requirement for starting an order is to adding an item to the cart.
상속: extends Object
파일 보기 프로젝트 열기: burnbright/silverstripe-shop 1 사용 예제들

공개 메소드들

메소드 설명
__clone ( ) singleton protection
__wakeup ( )
add ( Buyable $buyable, number $quantity = 1, unknown $filter = [] ) : boolean | OrderItem Adds an item to the cart
archiveorderid ( integer | null $requestedOrderId = null ) Store old cart id in session order history
clear ( boolean $write = true ) : boolean Empty / abandon the entire cart.
clearMessage ( )
curr ( ) : Order Shortened alias for ShoppingCart::singleton()->current()
current ( ) : Order Get the current order, or return null if it doesn't exist.
get ( Buyable $buyable, $customfilter = [] ) : OrderItem Finds an existing order item.
getCorrectBuyable ( Buyable $buyable ) : Buyable Ensure the proper buyable will be returned for a given buyable… This is being used to ensure a product with variations cannot be added to the cart… a Variation has to be added instead!
getMessage ( )
getMessageType ( )
remove ( Buyable $buyable, integer $quantity = null, $filter = [] ) : boolean Remove an item from the cart.
setCurrent ( Order $cart ) : ShoppingCart Set the current cart
setQuantity ( Buyable $buyable, integer $quantity = 1, $filter = [] ) : boolean | OrderItem Sets the quantity of an item in the cart.
singleton ( ) : ShoppingCart Access for only allowing access to one (singleton) ShoppingCart.

보호된 메소드들

메소드 설명
error ( $message ) Store a new error.
findOrMake ( ) : Order Helper that only allows orders to be started internally.
message ( string $message, string $type = "good" ) Store a message to be fed back to user.

비공개 메소드들

메소드 설명
findOrMakeItem ( Buyable $buyable, integer $quantity = 1, array $filter = [] ) : OrderItem Finds or makes an order item for a given product + filter.

메소드 상세

__clone() 공개 메소드

singleton protection
public __clone ( )

__wakeup() 공개 메소드

public __wakeup ( )

add() 공개 메소드

Adds an item to the cart
public add ( Buyable $buyable, number $quantity = 1, unknown $filter = [] ) : boolean | OrderItem
$buyable Buyable
$quantity number
$filter unknown
리턴 boolean | OrderItem false or the new/existing item

archiveorderid() 공개 메소드

Store old cart id in session order history
public archiveorderid ( integer | null $requestedOrderId = null )
$requestedOrderId integer | null optional parameter that denotes the order that was requested

clear() 공개 메소드

Empty / abandon the entire cart.
public clear ( boolean $write = true ) : boolean
$write boolean whether or not to write the abandoned order
리턴 boolean - true if successful, false if no cart found

clearMessage() 공개 메소드

public clearMessage ( )

curr() 공개 정적인 메소드

Shortened alias for ShoppingCart::singleton()->current()
public static curr ( ) : Order
리턴 Order

current() 공개 메소드

Get the current order, or return null if it doesn't exist.
public current ( ) : Order
리턴 Order

error() 보호된 메소드

Store a new error.
protected error ( $message )

findOrMake() 보호된 메소드

Helper that only allows orders to be started internally.
protected findOrMake ( ) : Order
리턴 Order

get() 공개 메소드

Finds an existing order item.
public get ( Buyable $buyable, $customfilter = [] ) : OrderItem
$buyable Buyable
리턴 OrderItem the item requested, or false

getCorrectBuyable() 공개 메소드

Ensure the proper buyable will be returned for a given buyable… This is being used to ensure a product with variations cannot be added to the cart… a Variation has to be added instead!
public getCorrectBuyable ( Buyable $buyable ) : Buyable
$buyable Buyable
리턴 Buyable

getMessage() 공개 메소드

public getMessage ( )

getMessageType() 공개 메소드

public getMessageType ( )

message() 보호된 메소드

Store a message to be fed back to user.
protected message ( string $message, string $type = "good" )
$message string
$type string - good, bad, warning

remove() 공개 메소드

Remove an item from the cart.
public remove ( Buyable $buyable, integer $quantity = null, $filter = [] ) : boolean
$buyable Buyable
$quantity integer - number of items to remove, or leave null for all items (default)
리턴 boolean success/failure

setCurrent() 공개 메소드

Set the current cart
public setCurrent ( Order $cart ) : ShoppingCart
$cart Order
리턴 ShoppingCart

setQuantity() 공개 메소드

Will automatically add or remove item, if necessary.
public setQuantity ( Buyable $buyable, integer $quantity = 1, $filter = [] ) : boolean | OrderItem
$buyable Buyable
$quantity integer
리턴 boolean | OrderItem false or the new/existing item

singleton() 공개 정적인 메소드

Access for only allowing access to one (singleton) ShoppingCart.
public static singleton ( ) : ShoppingCart
리턴 ShoppingCart