BasketService

This service class contains various methods used for manipulating the customers basket.
All public functions are available in the Twig template renderer.

Namespace

IO\Services

Properties
Type Name Description

BasketItemRepositoryContract

$basketItemRepository

This repository is used to manipulate basketItems

BasketRepositoryContract

$basketRepository

This repository is used to manipulate the customers basket

Checkout

$checkout

This service is used to manipulate the checkout

VatService

$vatService

This service provides methods for VAT related tasks

ContactRepositoryContract

$contactRepository

This repository is used to manipulate Contacts

CouponService

$couponService

This service provides functionality related to coupons

WebstoreConfigurationRepositoryContract

$webstoreConfigurationRepository

This repository is used to read webstore configuration

SessionStorageRepositoryContract

$sessionStorageRepository

This repository is used to read and write data of the session

array

$basketItems

Contains all current BasketItems

string

$template

Unused property

Deprecated

string

$pluginNamespace

Methods
public __construct($basketItemRepository, $checkout, $vatService, $contactRepository, $basketRepository, $vatInitService, $couponService, $webstoreConfigurationRepository, $sessionStorageRepository)

BasketService constructor.

Parameters

Type

Name

Description

BasketItemRepositoryContract

$basketItemRepository

Checkout

$checkout

VatService

$vatService

ContactRepositoryContract

$contactRepository

BasketRepositoryContract

$basketRepository

VatInitContract

$vatInitService

CouponService

$couponService

WebstoreConfigurationRepositoryContract

$webstoreConfigurationRepository

SessionStorageRepositoryContract

$sessionStorageRepository

public setTemplate($template)
Deprecated!

This method will not be supported in the future. Please refrain from using it as soon as possible.

Set the template property. Different templates need different data.

Parameters

Type

Name

Description

string

$template

public getBasketForTemplate():array

Gets the basket object with relevant data for the template renderer

public getBasket():Basket

Return the basket model

public getTotalVats():array

Gets all VATs applied to the basket

public getBasketQuantity():float \| int

Gets the total quantity of all basket items.

public getBasketItems():array

List the basket items

public getBasketItemsForOrder():array

List the basket items for order

public getBasketItemsForTemplate($template = "", $appendItemData = true):array

Get basket items with all relevant data for the template renderer.

Parameters

Type

Name

Description

string

$template

Unused parameter (legacy purposes)

bool

$appendItemData

Flag for adding item data to the basket items

public checkBasketItemsLang($language = "")

Remove basket items not having a valid language for the current basket configuration.

Parameters

Type

Name

Description

string

$language

The language in format ISO-639-1

public checkBasketItemsCurrency()
Deprecated!

Use checkBasketItemsByPrice instead

Remove basket items not having a valid price for the current basket configuration (referrer, currency,.

public checkBasketItemsByPrice():int

Remove basket items not having a valid price for the current basket configuration (referrer, currency,.

public getBasketItem($basketItemId, $appendVariation = true):array

Get a basket item

Parameters

Type

Name

Description

int | BasketItem

$basketItemId

The unique id of the basketItem

bool

$appendVariation

Flag for appending itemData to the BasketItem

public addBasketItem($data):array

Add an item to the basket or update the basket

Parameters

Type

Name

Description

array

$data

Contains the basket item

public updateBasketItem($basketItemId, $data):array

Update a basket item

Parameters

Type

Name

Description

int

$basketItemId

The unique id of the basket item

array

$data

Contains the updated basket item

public deleteBasketItem($basketItemId)

Delete an item from the basket

Parameters

Type

Name

Description

int

$basketItemId

The unique id of the basketItem

public findExistingOneByData($data):BasketItem

Check whether the item is already in the basket

Parameters

Type

Name

Description

array

$data

Contains the basket item to search for

public resetBasket()

Reset basket after execute payment / order created

public setBillingAddressId($billingAddressId)

Set the billing address id

Parameters

Type

Name

Description

int

$billingAddressId

public getBillingAddressId():int

Return the billing address id

public setDeliveryAddressId($deliveryAddressId)

Set the delivery address id

Parameters

Type

Name

Description

int

$deliveryAddressId

public getDeliveryAddressId():int

Return the delivery address id

public getMaxVatValue():float

Get the maximum vat value in basket.