PHP Interface Sonata\Component\Basket\BasketInterface

Show file Open project: sonata-project/ecommerce Interface Usage Examples

Public Methods

Method Description
addBasketElement ( Sonata\Component\Basket\BasketElementInterface $basketElement ) Add a basket element into the current basket.
buildPrices ( ) Compute the price of the basket.
clean ( ) remove basket element market as deleted.
countBasketElements ( ) : integer count number of element in the basket.
getBasketElements ( ) : Sonata\Component\Basket\BasketElementInterface[] return BasketElements.
getBillingAddress ( ) : Sonata\Component\Customer\AddressInterface
getBillingAddressId ( ) : integer
getCurrency ( ) : Sonata\Component\Currency\CurrencyInterface
getCustomer ( )
getCustomerId ( ) : integer
getDeliveryAddress ( ) : Sonata\Component\Customer\AddressInterface
getDeliveryAddressId ( ) : integer
getDeliveryMethod ( ) : Sonata\Component\Delivery\ServiceDeliveryInterface
getDeliveryMethodCode ( ) : string
getDeliveryPrice ( boolean $vat = false ) : float return the Delivery price.
getDeliveryVat ( ) : float returns the Delivery VAT rate.
getElement ( Sonata\Component\Product\ProductInterface $product ) : Sonata\Component\Basket\BasketElementInterface return the BasketElement depends on the $product or the position from the element stacks.
getLocale ( ) : string
getPaymentMethod ( ) : Sonata\Component\Payment\PaymentInterface
getPaymentMethodCode ( ) : string
getPositions ( ) : array
getProductPool ( ) : Pool
getSerializationFields ( ) : array Retrieves fields and associated values use for serialization Used by serialize method.
getTotal ( boolean $vat = false, boolean $recurrentOnly = null ) : float return the total of the basket if $vat = true, return price with vat if $recurrent_only = true, return price for recurrent product only if $recurrent_only = false, return price for non recurrent product only.
getUnserializationFields ( ) : array Retrieves fields for deserialization Used by unserialize method.
getVatAmount ( ) : float Returns the VAT of the current basket.
getVatAmounts ( ) : array Returns an array with all VAT amounts of the current basket.
hasBasketElements ( ) : boolean return true if the basket has some elements .
hasProduct ( Sonata\Component\Product\ProductInterface $product ) : boolean check if the basket contains $product.
hasRecurrentPayment ( ) : boolean return true if the basket has a least one recurrent product (subscription).
isAddable ( Sonata\Component\Product\ProductInterface $product ) : boolean Check if the product can be added to the basket.
isEmpty ( ) : boolean test is the basket has elements.
isValid ( boolean $elementsOnly = false ) : boolean Check is the basket is valid : elements, Payment and Delivery information.
removeBasketElement ( Sonata\Component\Basket\BasketElementInterface $element ) : Sonata\Component\Basket\BasketElementInterface delete an element from the basket depend on the $element. Element can be a product or a basket element.
removeElement ( Sonata\Component\Basket\BasketElementInterface $element ) : Sonata\Component\Basket\BasketElementInterface delete an element from the basket depend on the $element. Element can be a product or a basket element.
removeElements ( array $elementsToRemove ) deletes several elements from the basket.
reset ( boolean $full = true ) reset basket.
setBasketElements ( array $elements ) Warning : this method should be only used by the validation framework.
setBillingAddress ( Sonata\Component\Customer\AddressInterface $address = null ) set the Payment address.
setBillingAddressId ( integer $billingAddressId )
setCurrency ( Sonata\Component\Currency\CurrencyInterface $currency )
setCustomer ( Sonata\Component\Customer\CustomerInterface $customer = null )
setCustomerId ( integer $customerId )
setDeliveryAddress ( Sonata\Component\Customer\AddressInterface $address = null ) set the Delivery address.
setDeliveryAddressId ( integer $deliveryAddressId )
setDeliveryMethod ( Sonata\Component\Delivery\ServiceDeliveryInterface $method = null ) set the Delivery method.
setLocale ( string $locale )
setPaymentMethod ( Sonata\Component\Payment\PaymentInterface $method = null ) set Payment method.
setPaymentMethodCode ( string $paymentMethodCode )
setProductPool ( Pool $pool )

Method Details

addBasketElement() public method

Add a basket element into the current basket.
public addBasketElement ( Sonata\Component\Basket\BasketElementInterface $basketElement )
$basketElement Sonata\Component\Basket\BasketElementInterface

buildPrices() public method

Compute the price of the basket.
public buildPrices ( )

clean() public method

remove basket element market as deleted.
public clean ( )

countBasketElements() public method

count number of element in the basket.
public countBasketElements ( ) : integer
return integer

getBasketElements() public method

return BasketElements.
public getBasketElements ( ) : Sonata\Component\Basket\BasketElementInterface[]
return Sonata\Component\Basket\BasketElementInterface[]

getBillingAddress() public method

public getBillingAddress ( ) : Sonata\Component\Customer\AddressInterface
return Sonata\Component\Customer\AddressInterface

getBillingAddressId() public method

public getBillingAddressId ( ) : integer
return integer

getCurrency() public method

public getCurrency ( ) : Sonata\Component\Currency\CurrencyInterface
return Sonata\Component\Currency\CurrencyInterface

getCustomer() public method

public getCustomer ( )

getCustomerId() public method

public getCustomerId ( ) : integer
return integer

getDeliveryAddress() public method

public getDeliveryAddress ( ) : Sonata\Component\Customer\AddressInterface
return Sonata\Component\Customer\AddressInterface

getDeliveryAddressId() public method

public getDeliveryAddressId ( ) : integer
return integer

getDeliveryMethod() public method

public getDeliveryMethod ( ) : Sonata\Component\Delivery\ServiceDeliveryInterface
return Sonata\Component\Delivery\ServiceDeliveryInterface

getDeliveryMethodCode() public method

public getDeliveryMethodCode ( ) : string
return string

getDeliveryPrice() public method

return the Delivery price.
public getDeliveryPrice ( boolean $vat = false ) : float
$vat boolean
return float

getDeliveryVat() public method

returns the Delivery VAT rate.
public getDeliveryVat ( ) : float
return float

getElement() public method

return the BasketElement depends on the $product or the position from the element stacks.
public getElement ( Sonata\Component\Product\ProductInterface $product ) : Sonata\Component\Basket\BasketElementInterface
$product Sonata\Component\Product\ProductInterface
return Sonata\Component\Basket\BasketElementInterface

getLocale() public method

public getLocale ( ) : string
return string

getPaymentMethod() public method

public getPaymentMethod ( ) : Sonata\Component\Payment\PaymentInterface
return Sonata\Component\Payment\PaymentInterface

getPaymentMethodCode() public method

public getPaymentMethodCode ( ) : string
return string

getPositions() public method

public getPositions ( ) : array
return array

getProductPool() public method

public getProductPool ( ) : Pool
return Sonata\Component\Product\Pool

getSerializationFields() public method

Retrieves fields and associated values use for serialization Used by serialize method.
public getSerializationFields ( ) : array
return array

getTotal() public method

return the total of the basket if $vat = true, return price with vat if $recurrent_only = true, return price for recurrent product only if $recurrent_only = false, return price for non recurrent product only.
public getTotal ( boolean $vat = false, boolean $recurrentOnly = null ) : float
$vat boolean Returns price including VAT?
$recurrentOnly boolean Is recurrent only?
return float

getUnserializationFields() public method

Retrieves fields for deserialization Used by unserialize method.
public getUnserializationFields ( ) : array
return array

getVatAmount() public method

Returns the VAT of the current basket.
public getVatAmount ( ) : float
return float

getVatAmounts() public method

Returns an array with all VAT amounts of the current basket.
public getVatAmounts ( ) : array
return array

hasBasketElements() public method

..
public hasBasketElements ( ) : boolean
return boolean

hasProduct() public method

check if the basket contains $product.
public hasProduct ( Sonata\Component\Product\ProductInterface $product ) : boolean
$product Sonata\Component\Product\ProductInterface
return boolean

hasRecurrentPayment() public method

@return bool
public hasRecurrentPayment ( ) : boolean
return boolean

isAddable() public method

Check if the product can be added to the basket.
public isAddable ( Sonata\Component\Product\ProductInterface $product ) : boolean
$product Sonata\Component\Product\ProductInterface
return boolean

isEmpty() public method

test is the basket has elements.
public isEmpty ( ) : boolean
return boolean

isValid() public method

if $element_only is set to true, only elements are checked
public isValid ( boolean $elementsOnly = false ) : boolean
$elementsOnly boolean
return boolean

removeBasketElement() public method

delete an element from the basket depend on the $element. Element can be a product or a basket element.
public removeBasketElement ( Sonata\Component\Basket\BasketElementInterface $element ) : Sonata\Component\Basket\BasketElementInterface
$element Sonata\Component\Basket\BasketElementInterface
return Sonata\Component\Basket\BasketElementInterface

removeElement() public method

delete an element from the basket depend on the $element. Element can be a product or a basket element.
Deprecation: Use RemoveBasketElement instead
public removeElement ( Sonata\Component\Basket\BasketElementInterface $element ) : Sonata\Component\Basket\BasketElementInterface
$element Sonata\Component\Basket\BasketElementInterface
return Sonata\Component\Basket\BasketElementInterface

removeElements() public method

deletes several elements from the basket.
public removeElements ( array $elementsToRemove )
$elementsToRemove array

reset() public method

reset basket.
public reset ( boolean $full = true )
$full boolean

setBasketElements() public method

Warning : this method should be only used by the validation framework.
public setBasketElements ( array $elements )
$elements array

setBillingAddress() public method

set the Payment address.
public setBillingAddress ( Sonata\Component\Customer\AddressInterface $address = null )
$address Sonata\Component\Customer\AddressInterface

setBillingAddressId() public method

public setBillingAddressId ( integer $billingAddressId )
$billingAddressId integer

setCurrency() public method

public setCurrency ( Sonata\Component\Currency\CurrencyInterface $currency )
$currency Sonata\Component\Currency\CurrencyInterface

setCustomer() public method

public setCustomer ( Sonata\Component\Customer\CustomerInterface $customer = null )
$customer Sonata\Component\Customer\CustomerInterface

setCustomerId() public method

public setCustomerId ( integer $customerId )
$customerId integer

setDeliveryAddress() public method

set the Delivery address.
public setDeliveryAddress ( Sonata\Component\Customer\AddressInterface $address = null )
$address Sonata\Component\Customer\AddressInterface

setDeliveryAddressId() public method

public setDeliveryAddressId ( integer $deliveryAddressId )
$deliveryAddressId integer

setDeliveryMethod() public method

set the Delivery method.
public setDeliveryMethod ( Sonata\Component\Delivery\ServiceDeliveryInterface $method = null )
$method Sonata\Component\Delivery\ServiceDeliveryInterface

setLocale() public method

public setLocale ( string $locale )
$locale string

setPaymentMethod() public method

set Payment method.
public setPaymentMethod ( Sonata\Component\Payment\PaymentInterface $method = null )
$method Sonata\Component\Payment\PaymentInterface

setPaymentMethodCode() public method

public setPaymentMethodCode ( string $paymentMethodCode )
$paymentMethodCode string

setProductPool() public method

public setProductPool ( Pool $pool )
$pool Sonata\Component\Product\Pool