Blesta Source Documentation

AbstractServiceItems implements ServiceItemsInterface uses Meta

AbstractYes

Abstract builder for service items

Attributes
#[AllowDynamicProperties]
Table of Contents

Interfaces

ServiceItemsInterface Service item builder interface

Properties

$discounts
$itemFactory
$options
$pricingFactory
$serviceOptions
$settings
$taxes
$packageKeys
$packageOptionKeys
$serviceKeys
$serviceOptionKeys

Methods

__construct() Init
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
getDiscounts() Retrieves a list of available discounts
getTaxes() Retrieves a list of MetaTaxPrice objects that may be applied
setDefaultOptions() Combines the default options with the given options
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

$packageKeys

private string $packageKeys = ['item' => 'package-%1$s', 'setup' => 'package-%1$s-setup', 'cancel' => 'package-%1$s-cancel']

The item price keys for a package

$packageOptionKeys

private string $packageOptionKeys = ['item' => 'package-%1$s-option-%2$s', 'setup' => 'package-%1$s-option-%2$s-setup', 'cancel' => 'package-%1$s-option-%2$s-cancel']

The item price keys for a package option

$serviceKeys

private string $serviceKeys = ['item' => 'service-%1$s', 'setup' => 'service-%1$s-setup', 'cancel' => 'service-%1$s-cancel']

The item price keys for a service

$serviceOptionKeys

private string $serviceOptionKeys = ['item' => 'service-%1$s-option-%2$s', 'setup' => 'service-%1$s-option-%2$s-setup', 'cancel' => 'service-%1$s-option-%2$s-cancel']

The item price keys for a service option

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

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

getDiscounts()

Retrieves a list of available discounts

private getDiscounts(array<string|int, mixed> $packageIds) : array<string|int, mixed>
Parameters
$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>

An array of MetaDiscountPrice objects that may be applied

getTaxes()

Retrieves a list of MetaTaxPrice objects that may be applied

private getTaxes() : array<string|int, mixed>
Return values
array<string|int, mixed>

A list of MetaTaxPrice objects

setDefaultOptions()

Combines the default options with the given options

private setDefaultOptions() : mixed

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