Blesta Source Documentation

ServiceDataBuilder extends AbstractServiceDataBuilder

Service data builder

Table of Contents

Properties

$discounts
$formatFactory
$itemFactory
$options
$presenterFactory
$pricingFactory
$serviceFactory
$settings
$taxes

Methods

__construct() Init
build() Retrieve a ServiceDataPresenter
discounts() Sets all discounts
options() Sets any key/value custom options
settings() Sets a list of settings
taxes() Sets all tax rules
formatDiscounts() Formats the discounts
formatOptions() Formats the options
formatSettings() Formats the settings
formatTaxes() Formats the taxes
format() Formats the service data into items
Properties

$discounts

protected array<string|int, mixed> $discounts = []

An array of stdClass objects representing each discount

$options

protected array<string|int, mixed> $options = []

All key/value custom options

$settings

protected array<string|int, mixed> $settings = []

All key/value settings

$taxes

protected array<string|int, mixed> $taxes = []

An array of stdClass objects representing each tax rule

Methods

__construct()

Init

public __construct(ServiceFactory $serviceFactory, FormatFactory $formatFactory, PricingFactory $pricingFactory, PresenterFactory $presenterFactory, ItemFactory $itemFactory) : mixed
Parameters
$serviceFactory : ServiceFactory

An instance of the ServiceFactory

$formatFactory : FormatFactory

An instance of the FormatFactory

$pricingFactory : PricingFactory

An instance of the PricingFactory

$presenterFactory : PresenterFactory

An instance of the PresenterFactory

$itemFactory : ItemFactory

An instance of the ItemFactory

build()

Retrieve a ServiceDataPresenter

public build(array<string|int, mixed> $vars, stdClass $package, stdClass $pricing, array<string|int, mixed> $options) : ServiceDataPresenter
Parameters
$vars : array<string|int, mixed>

An array of input data, including:

  • pricing_id The ID of the selected package pricing
  • qty The service quantity (default 1)
  • override_price The new override price
  • override_currency The new override currency
  • configoptions An array of config options where each key is the option ID and the value is the selected option value
$package : stdClass

An stdClass object representing the package selected for use, including:

  • id The package ID
  • name The package's name
  • taxable 1 or 0, whether the package is taxable
  • prorata_day The package pro rata day
  • prorata_cutoff The package pro rata cutoff day
$pricing : stdClass

An stdClass object representing the selected package pricing, including:

  • id The package pricing ID
  • package_id The package ID
  • term The pricing term
  • period The pricing period
  • setup_fee The pricing setup fee
  • cancel_fee The pricing cancelation fee
  • currency The pricing currency
$options : array<string|int, mixed>

An array of stdClass objects representing all package options, each including:

  • id The option ID
  • label The option label
  • name The option name
  • type The option type
  • values An array of stdClass objects representing each option value, including:
    • id The option value ID
    • option_id The option ID
    • value The option value
    • min The minimum value
    • max The maximum value
    • step The step value
    • pricing An array whose first index contains an stdClass object representing the option value pricing, including:
      • id The option value pricing ID
      • pricing_id The pricing ID
      • option_value_id The option value ID
      • term The pricing term
      • period The pricing period
      • price The option value price
      • setup_fee The option value setup fee
      • cancel_fee The option value cancelation fee
      • currency The option value currency
Return values
ServiceDataPresenter

An instance of the ServiceDataPresenter

discounts()

Sets all discounts

public discounts(array<string|int, mixed> $discounts) : this
Parameters
$discounts : array<string|int, mixed>

An array of stdClass objects representing each coupon that applies, containing:

  • id The coupon ID
  • code The coupon code
  • used_qty The number of times the coupon has been used
  • max_qty The max number of coupon uses
  • start_date The date the coupon begins
  • end_date The date the coupon ends
  • status The coupon status
  • type The type of coupon as it applies to packages (exclusive, inclusive)
  • recurring 1 or 0, whether the coupon applies to recurring services
  • limit_recurring 1 or 0, whether the coupon limitations apply to recurring services
  • apply_package_options 1 or 0, whether the coupon applies to a service's package options
  • amounts An array of stdClass objects representing each coupon amount, containing:
    • coupon_id The coupon ID
    • currency The coupon amount currency
    • amount The coupon amount
    • type The coupon amount type (percent, amount)
  • packages An array of stdClass objects representing each assigned coupon package, containing:
    • coupon_id The coupon ID
    • package_id The assigned package ID
Return values
this

options()

Sets any key/value custom options

public options(array<string|int, mixed> $options) : this
Parameters
$options : array<string|int, mixed>

An array of custom options:

  • includeSetupFees (optional) true/false, whether to include applicable setup fees. Default false.
  • includeCancelFees (optional) true/false, whether to include applicable cancel fees. Default false.
  • applyDate* (optional) The effective date the items apply. Coupons only apply with respect to this date. Default now.
  • startDate* (optional) The effective date the service term begins. Services are dated from this startDate unless overridden by proration. Default now.
  • recur (optional) true/false, whether to treat the service as recurring, i.e., the service already exists and is renewing. May affect coupon discounts. Default false.
  • transfer (optional) true/false, whether to use the transfer price or not, i.e., the service is a domain being transferred. May affect coupon discounts. Default false.
  • renewal (optional) true/false, whether to use the renewal price or not, i.e., the service is a domain being renewed. May affect coupon discounts. Default false.
  • cycles (optional) The amount of term cycles the service will be renewed. Default 1
  • prorateStartDate* (optional) datetime stamp. If set, will prorate the service from this date to the prorateEndDate
  • prorateEndDate* (optional) datetime stamp. If set, will override the otherwise calculated prorate end date.
  • prorateEndDateData* (optional) datetime stamp. If set, will override the otherwise set prorateEndDate when included with the Service Change Presenter only. This is typically used to prorate a service from its current renew date to a new renew date by providing the new renew date here while the service's current renew date is the prorateEndDate.
  • config_options (optional) array, a list of the config options currently on a service which is having a price change calculated.
  • upgrade (optional) true/false, whether this price is being calculated for a package upgrade.
  • option_currency (optional, for service changes) The ISO 4217 3-character currency code to which option prices should be converted
  • service_currency (optional, for service changes) The ISO 4217 3-character currency code to which service prices should be converted
Return values
this

settings()

Sets a list of settings

public settings(array<string|int, mixed> $settings) : this
Parameters
$settings : array<string|int, mixed>

An array containing all client and company settings as key/value pairs

Return values
this

taxes()

Sets all tax rules

public taxes(array<string|int, mixed> $taxes) : this
Parameters
$taxes : array<string|int, mixed>

An array of stdClass objects representing each tax rule that applies, containing:

  • id The tax ID
  • company_id The company ID
  • level The tax level
  • name The name of the tax
  • amount The tax amount
  • type The tax type (inclusive, exclusive)
  • status The tax status
Return values
this

formatDiscounts()

Formats the discounts

protected formatDiscounts(DiscountFormatterInterface $formatter, ItemCollection $collection) : ItemCollection
Parameters
$formatter : DiscountFormatterInterface

The formatter

$collection : ItemCollection

The item collection to append formatted discounts to

Return values
ItemCollection

A collection of Items

formatTaxes()

Formats the taxes

protected formatTaxes(TaxFormatterInterface $formatter, ItemCollection $collection) : ItemCollection
Parameters
$formatter : TaxFormatterInterface

The formatter

$collection : ItemCollection

The item collection to append formatted taxes to

Return values
ItemCollection

A collection of Items

format()

Formats the service data into items

private format(array<string|int, mixed> $vars, stdClass $package, stdClass $pricing, array<string|int, mixed> $packageOptions) : stdClass
Parameters
$vars : array<string|int, mixed>

An array of service data representing the service

$package : stdClass

An stdClass object representing the package

$pricing : stdClass

An stdClass object representing the pricing

$packageOptions : array<string|int, mixed>
Return values
stdClass

An stdClass of formatted items representing the service

Tags
subpackage

core.Pricing.Presenter.Build.ServiceData

copyright

Copyright (c) 2019, Phillips Data, Inc.

license

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

link

Blesta


        
On this page

Search results