Skip to content
Last updated

WHMCS\Product\Addon

Class · extends AbstractModel · implements PricedEntityInterface, AddonInterface

tbladdons model class

Traits

  • BillingTrait
  • MarketConnectTrait
  • OnDemandRenewalTrait

Constants

NameDescription
PROVISIONING_TYPE_FEATURE
PROVISIONING_TYPE_STANDARD

Methods

boot

public static function boot()

scopeProductId

public function scopeProductId(Builder $query, int $productId): Builder

Get all addon available for a given product id

Parameters

TypeNameDescription
Builder$query
int$productId

Returns Builder

scopeShowOnOrderForm

public function scopeShowOnOrderForm(Builder $query)

A scope to show Addons available on OrderForm

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeIsHidden

public function scopeIsHidden(Builder $query)

A scope to show Addons hidden on OrderForm

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeIsNotHidden

public function scopeIsNotHidden(Builder $query)

A scope to show Addons not hidden on OrderForm

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeIsRetired

public function scopeIsRetired(Builder $query)

A scope to show Addons that should not be displayed on OrderForm

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeIsNotRetired

public function scopeIsNotRetired(Builder $query)

A scope to show Addons that may be displayed on OrderForm

Parameters

TypeNameDescription
Builder$query

Returns Builder

scopeAvailableOnOrderForm

public function scopeAvailableOnOrderForm(Builder $query, array $addons = [])

A scope to show Addons available on OrderForm using hidden and show on order options.

Parameters

TypeNameDescription
Builder$query
int[]$addonsAn array of addon ids that should be preselected on OrderForm.

Returns Builder

scopeSorted

public function scopeSorted($query)

Sort by display order.

Returns Builder

welcomeEmailTemplate

public function welcomeEmailTemplate()

An addon has one welcome email template.

Returns \Illuminate\Database\Eloquent\Relations\HasOne

getNameAttribute

public function getNameAttribute($name)

Get the addon name - this will override the output from the db value if set in Lang.

Parameters

TypeNameDescription
string$nameThe value from the database

Returns string

getDescriptionAttribute

public function getDescriptionAttribute($description)

Get the addon description - this will override the output from the db value if set in Lang.

Parameters

TypeNameDescription
string$descriptionThe value from the database

Returns string

customFields

public function customFields()

Returns \Illuminate\Database\Eloquent\Relations\HasMany

serviceAddons

public function serviceAddons()

Returns \Illuminate\Database\Eloquent\Relations\HasMany

dbPricing

public function dbPricing(): HasMany

moduleConfiguration

public function moduleConfiguration()

Returns \Illuminate\Database\Eloquent\Relations\HasMany

translatedNames

public function translatedNames()

Return the translated names for the specific addon

Returns \Illuminate\Database\Eloquent\Relations\HasMany\|\WHMCS\Language\DynamicTranslation[]

translatedDescriptions

public function translatedDescriptions()

Return the translated names for the specific addon

Returns \Illuminate\Database\Eloquent\Relations\HasMany\|\WHMCS\Language\DynamicTranslation[]

getAddonName

public static function getAddonName($addonId, $fallback = '', $language = null)

Obtain the addon name for the current language, passed language or fallback to the currently defined value for the product.

Parameters

TypeNameDescription
int$addonId
string$fallback- override the language fallback value
string$language

Returns string

getAddonDescription

public static function getAddonDescription($addonId, $fallback = '', $language = null)

Obtain the addon description for the current language, passed language or fallback to the currently defined value for the product.

Parameters

TypeNameDescription
int$addonId
string$fallback
string$language

Returns string

pricing

public function pricing($currency = null): Pricing

Get available cycles and pricing for addon.

Parameters

TypeNameDescription
array|null$currencyOnly required on first call.

Returns Pricing

isFree

public function isFree(): bool

Is product a free product.

Returns bool

isOneTime

public function isOneTime(): bool

Is product a one time product.

Returns bool

scopeMarketConnect

public function scopeMarketConnect(Builder $query)

Quick filter for module = marketconnect.

Parameters

TypeNameDescription
Builder$query

Returns Builder

getProductKeyAttribute

public function getProductKeyAttribute()

Get product key attribute for the current product addon entity.

Returns string

isMarketConnectAddon

public function isMarketConnectAddon()

Is this a MarketConnect addon?

Returns bool

getServiceKeyAttribute

public function getServiceKeyAttribute($value)

Get service key attribute for the current product addon entity.

Parameters

TypeNameDescription
string$value

Returns string

isValidForUpgrade

public function isValidForUpgrade(Addon $addon)

Validate a given addon is a valid upgrade candidate.

For MarketConnect, validates upgrade product service key matches current product key.

Parameters

TypeNameDescription
Addon$addon

Returns bool

isVisibleOnOrderForm

public function isVisibleOnOrderForm(array $addonIds = [])

Check if the addon should be visible on the orderform.

Parameters

TypeNameDescription
int[]$addonIdsAn array of addonids to preselect on the orderform

Returns bool

getAddonDropdownValues

public static function getAddonDropdownValues(int $currentAddonId = 0): array

Get an array of id => name addons that should appear in an addon dropdown.

Parameters

TypeNameDescription
int$currentAddonId

Returns array

emailMarketerRules

public function emailMarketerRules()

getAvailableBillingCycles

public function getAvailableBillingCycles(): array

Get available billing cycles for product.

Returns string[]

duplicate

public function duplicate(string $newAddonName): Addon

Replicate Product Addon and Pricing. New object uses provided string as name.

Parameters

TypeNameDescription
string$newAddonName

Returns Addon

getProvisioningTypeAttribute

public function getProvisioningTypeAttribute(): string

Returns string

getOrderLineItemProductGroupName

public function getOrderLineItemProductGroupName(): string

overrideOnDemandRenewal

public function overrideOnDemandRenewal(): HasOne

On-demand renewal override settings if not null

Returns HasOne

overridingOnDemandRenewal

public function overridingOnDemandRenewal(bool $enable, int $monthly, int $quarterly, int $semiannually, int $annually, int $biennially, int $triennially): self

Override on-demand renewal settings

Parameters

TypeNameDescription
bool$enable
int$monthly
int$quarterly
int$semiannually
int$annually
int$biennially
int$triennially

Returns Addon