Blesta Source Documentation

ServiceDataItems extends AbstractServiceItems

Build service data items

Table of Contents

Properties

$discounts
$itemFactory
$options
$pricingFactory
$serviceOptions
$settings
$taxes

Methods

__construct() Init
build() Builds service information into an ItemPriceCollection
getDateRange() Retrieves the service date range
getKey() Creates a key using the given name and type
getMeta() Retrieves all meta information set on a meta item combined together
getMetaFromCollection() Retrieves all meta information set on an item collection
makeMetaItemPrices() Creates a list of MetaItemPrices from a set of items
setDiscounts() Updates the given MetaItemPrices to assign discounts
setPackageOptions() Sets the package options for coupon validation
setServiceOptions() Sets the service options for coupon validation
setTaxes() Updates the given MetaItemPrices to assign taxes
fetchOption() Retrieves the given option/value pair from the set of options
keyOptions() Retrieves a list of service options keyed by ID
makeItems() Creates a set of MetaItemPrices for the service data
makeOptionItems() Creates a set of MetaItemPrices for each valid package option
updateMeta() Updates the given MetaItemInterface to set the first meta item with the given data
Properties

$serviceOptions

protected ItemCollection $serviceOptions

Current service options for coupon validation

Methods

__construct()

Init

public __construct(PricingFactory $pricingFactory, ItemFactory $itemFactory, ItemInterface $settings[, ItemCollection $taxes = null ][, ItemCollection $discounts = null ][, ItemInterface $options = null ]) : mixed
Parameters
$pricingFactory : PricingFactory

An instance of the PricingFactory

$itemFactory : ItemFactory

An instance of the ItemFactory

$settings : ItemInterface

An item containing a set of settings

$taxes : ItemCollection = null

A collection of items representing taxes

$discounts : ItemCollection = null

A collection of items representing discounts

$options : ItemInterface = null

An item containing a set of custom options

build()

Builds service information into an ItemPriceCollection

public build(ItemInterface $service, ItemInterface $package, ItemInterface $pricing, ItemCollection $options) : ItemPriceCollection
Parameters
$service : ItemInterface

An item representing the service

$package : ItemInterface

An item representing the package

$pricing : ItemInterface

An item representing the pricing

$options : ItemCollection

A collection representing the service options

Return values
ItemPriceCollection

getDateRange()

Retrieves the service date range

protected getDateRange(stdClass $pricing) : array<string|int, mixed>
Parameters
$pricing : stdClass

An stdClass object representing pricing, including:

  • term The pricing term
  • period The pricing period
Return values
array<string|int, mixed>

A key => value array containing:

  • startDate The start date of the service
  • endDate The end date of the service

getKey()

Creates a key using the given name and type

protected getKey(string $name, string $type) : mixed
Parameters
$name : string

The name of the key to retrieve ('service' or 'serviceoption')

$type : string

The type of key ('item', 'setup', 'cancel')

getMeta()

Retrieves all meta information set on a meta item combined together

protected getMeta(MetaItemInterface $item) : array<string|int, mixed>
Parameters
$item : MetaItemInterface

The item whose meta information to retrieve

Return values
array<string|int, mixed>

An array of all meta data

getMetaFromCollection()

Retrieves all meta information set on an item collection

protected getMetaFromCollection(ItemCollection $collection) : array<string|int, mixed>
Parameters
$collection : ItemCollection

An item collection

Return values
array<string|int, mixed>

An array of all meta data

makeMetaItemPrices()

Creates a list of MetaItemPrices from a set of items

protected makeMetaItemPrices(array<string|int, mixed> $items) : An
Parameters
$items : array<string|int, mixed>

An array of items that each must contain:

  • price The price of the item
  • qty The quantity count of the item
  • key The item's key
  • meta Meta information about the item (optional)
Return values
An

array of MetaItemPrice objects representing each item

setDiscounts()

Updates the given MetaItemPrices to assign discounts

protected setDiscounts(array<string|int, mixed> $itemPrices, array<string|int, mixed> $packageIds) : array<string|int, mixed>
Parameters
$itemPrices : array<string|int, mixed>

An array of MetaItemPrices to assign discounts for

$packageIds : array<string|int, mixed>

One of the following:

  • An array of package IDs that the discount must apply to
  • An array of package IDs mapped to periods and terms [packageID => [period => [term, term]]] that the discount must apply to
Return values
array<string|int, mixed>

The MetaItemPrices with discounts assigned

setPackageOptions()

Sets the package options for coupon validation

protected setPackageOptions(ItemCollection $options) : mixed
Parameters
$options : ItemCollection

A collection of service options

setServiceOptions()

Sets the service options for coupon validation

protected setServiceOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

A collection of service options

setTaxes()

Updates the given MetaItemPrices to assign taxes

protected setTaxes(array<string|int, mixed> $itemPrices) : array<string|int, mixed>
Parameters
$itemPrices : array<string|int, mixed>

An array of MetaItemPrices to assign taxes for

Return values
array<string|int, mixed>

The MetaTaxPrices with taxes assigned

fetchOption()

Retrieves the given option/value pair from the set of options

private fetchOption(array<string|int, mixed> $options, int $optionId, mixed $value) : stdClass|bool
Parameters
$options : array<string|int, mixed>

An array of package option Items keyed by option ID

$optionId : int

The ID of the option to retrieve

$value : mixed

The value of the option selected

Return values
stdClass|bool

The stdClass object representing the selected option, otherwise false

keyOptions()

Retrieves a list of service options keyed by ID

private keyOptions(ItemCollection $options) : array<string|int, mixed>
Parameters
$options : ItemCollection
Return values
array<string|int, mixed>

An array of package options keyed by ID

makeItems()

Creates a set of MetaItemPrices for the service data

private makeItems(ItemInterface $service, ItemInterface $pricing, ItemInterface $package) : array<string|int, mixed>
Parameters
$service : ItemInterface

An item representing the service data

$pricing : ItemInterface

An item representing the pricing

$package : ItemInterface

An item representing the package

Return values
array<string|int, mixed>

An array of MetaItemPrices

makeOptionItems()

Creates a set of MetaItemPrices for each valid package option

private makeOptionItems(array<string|int, mixed> $options, ItemInterface $service, ItemInterface $package) : array<string|int, mixed>
Parameters
$options : array<string|int, mixed>

An array of all options keyed by option ID

$service : ItemInterface

An item representing the service

$package : ItemInterface

An item representing the package

Return values
array<string|int, mixed>

An array of MetaItemPrices

updateMeta()

Updates the given MetaItemInterface to set the first meta item with the given data

private updateMeta(MetaItemInterface $item, array<string|int, mixed> $meta) : MetaItemInterface
Parameters
$item : MetaItemInterface

The item whose meta information to update

$meta : array<string|int, mixed>

The meta information to update the item with

Return values
MetaItemInterface

The updated item

Tags
subpackage

core.Pricing.Presenter.Items.Service

copyright

Copyright (c) 2019, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results