Blesta Source Documentation

ServiceItems extends AbstractServiceItems

Build service 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
makeItems() Creates a set of MetaItemPrices for the service
makeOptionItems() Creates a set of MetaItemPrices for each valid service 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

makeItems()

Creates a set of MetaItemPrices for the service

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

An item representing the service

$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 service option

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

A collection representing the service options

$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