PHP Class OrderItem, silvershop-core

Mostra file Open project: burnbright/silverstripe-shop Class Usage Examples

Public Methods

Method Description
Buyable ( ) Get the buyable object related to this item.
Image ( ) Get the buyable image.
QuantityField ( ) : ShopQuantityField
Total ( ) Get calculated total, or stored total depending on whether the order is in cart
UnitPrice ( ) Get unit price for this item.
addLink ( ) : string
onBeforeWrite ( ) Recalculate total before saving to database.
onPayment ( ) * Event handler called when an order is fully paid for.
onPlacement ( ) Event handlier called for last time saving/processing, before item permanently stored in database.
removeLink ( ) : string
removeallLink ( ) : string
setQuantity ( integer $val ) Prevent quantity being below 1.
setUnitPrice ( $val ) Prevent unit price ever being below 0
setquantityLink ( ) : string
uniquedata ( ) Intersects this item's required_fields with the data record.

Protected Methods

Method Description
calculatetotal ( ) Calculates the total for this item.

Method Details

Buyable() public method

Get the buyable object related to this item.
public Buyable ( )

Image() public method

Also serves as a standardised placeholder for overriding in subclasses.
public Image ( )

QuantityField() public method

public QuantityField ( ) : ShopQuantityField
return ShopQuantityField

Total() public method

Get calculated total, or stored total depending on whether the order is in cart
public Total ( )

UnitPrice() public method

Fetches from db, or Buyable, based on order status.
public UnitPrice ( )

calculatetotal() protected method

Generally called by onBeforeWrite
protected calculatetotal ( )

onBeforeWrite() public method

Recalculate total before saving to database.
public onBeforeWrite ( )

onPayment() public method

* Event handler called when an order is fully paid for.
public onPayment ( )

onPlacement() public method

This should only be called when order is transformed from Cart to Order, aka being 'placed'.
public onPlacement ( )

setQuantity() public method

0 quantity means it should instead be deleted.
public setQuantity ( integer $val )
$val integer new quantity to set

setUnitPrice() public method

Prevent unit price ever being below 0
public setUnitPrice ( $val )

uniquedata() public method

This is used for uniquely adding items to the cart.
public uniquedata ( )