# WHMCS\Product\Addon

`Class` · extends `AbstractModel` · implements `PricedEntityInterface`, `AddonInterface`

tbladdons model class

## Traits

- `BillingTrait`
- `MarketConnectTrait`
- `OnDemandRenewalTrait`


## Constants

| Name | Description |
|  --- | --- |
| `PROVISIONING_TYPE_FEATURE` |  |
| `PROVISIONING_TYPE_STANDARD` |  |


## Methods

### boot

```php
public static function boot()
```

### scopeProductId

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

Get all addon available for a given product id

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |
| `int` | `$productId` |  |


**Returns** `Builder`

### scopeShowOnOrderForm

```php
public function scopeShowOnOrderForm(Builder $query)
```

A scope to show Addons available on OrderForm

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### scopeIsHidden

```php
public function scopeIsHidden(Builder $query)
```

A scope to show Addons hidden on OrderForm

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### scopeIsNotHidden

```php
public function scopeIsNotHidden(Builder $query)
```

A scope to show Addons not hidden on OrderForm

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### scopeIsRetired

```php
public function scopeIsRetired(Builder $query)
```

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### scopeIsNotRetired

```php
public function scopeIsNotRetired(Builder $query)
```

A scope to show Addons that may be displayed on OrderForm

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### scopeAvailableOnOrderForm

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

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |
| `int[]` | `$addons` | An array of addon ids that should be preselected on OrderForm. |


**Returns** `Builder`

### scopeSorted

```php
public function scopeSorted($query)
```

Sort by display order.

**Returns** `Builder`

### welcomeEmailTemplate

```php
public function welcomeEmailTemplate()
```

An addon has one welcome email template.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasOne`

### getNameAttribute

```php
public function getNameAttribute($name)
```

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$name` | The value from the database |


**Returns** `string`

### getDescriptionAttribute

```php
public function getDescriptionAttribute($description)
```

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$description` | The value from the database |


**Returns** `string`

### customFields

```php
public function customFields()
```

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### serviceAddons

```php
public function serviceAddons()
```

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### dbPricing

```php
public function dbPricing(): HasMany
```

### moduleConfiguration

```php
public function moduleConfiguration()
```

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### translatedNames

```php
public function translatedNames()
```

Return the translated names for the specific addon

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

### translatedDescriptions

```php
public function translatedDescriptions()
```

Return the translated names for the specific addon

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

### getAddonName

```php
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**

| Type | Name | Description |
|  --- | --- | --- |
| `int` | `$addonId` |  |
| `string` | `$fallback` | - override the language fallback value |
| `string` | `$language` |  |


**Returns** `string`

### getAddonDescription

```php
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**

| Type | Name | Description |
|  --- | --- | --- |
| `int` | `$addonId` |  |
| `string` | `$fallback` |  |
| `string` | `$language` |  |


**Returns** `string`

### pricing

```php
public function pricing($currency = null): Pricing
```

Get available cycles and pricing for addon.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `array|null` | `$currency` | Only required on first call. |


**Returns** `Pricing`

### isFree

```php
public function isFree(): bool
```

Is product a free product.

**Returns** `bool`

### isOneTime

```php
public function isOneTime(): bool
```

Is product a one time product.

**Returns** `bool`

### scopeMarketConnect

```php
public function scopeMarketConnect(Builder $query)
```

Quick filter for module = marketconnect.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### getProductKeyAttribute

```php
public function getProductKeyAttribute()
```

Get product key attribute for the current product addon entity.

**Returns** `string`

### isMarketConnectAddon

```php
public function isMarketConnectAddon()
```

Is this a MarketConnect addon?

**Returns** `bool`

### getServiceKeyAttribute

```php
public function getServiceKeyAttribute($value)
```

Get service key attribute for the current product addon entity.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$value` |  |


**Returns** `string`

### isValidForUpgrade

```php
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**

| Type | Name | Description |
|  --- | --- | --- |
| `Addon` | `$addon` |  |


**Returns** `bool`

### isVisibleOnOrderForm

```php
public function isVisibleOnOrderForm(array $addonIds = [])
```

Check if the addon should be visible on the orderform.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `int[]` | `$addonIds` | An array of addonids to preselect on the orderform |


**Returns** `bool`

### getAddonDropdownValues

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

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `int` | `$currentAddonId` |  |


**Returns** `array`

### emailMarketerRules

```php
public function emailMarketerRules()
```

### getAvailableBillingCycles

```php
public function getAvailableBillingCycles(): array
```

Get available billing cycles for product.

**Returns** `string[]`

### duplicate

```php
public function duplicate(string $newAddonName): Addon
```

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$newAddonName` |  |


**Returns** `Addon`

### getProvisioningTypeAttribute

```php
public function getProvisioningTypeAttribute(): string
```

**Returns** `string`

### getOrderLineItemProductGroupName

```php
public function getOrderLineItemProductGroupName(): string
```

### overrideOnDemandRenewal

```php
public function overrideOnDemandRenewal(): HasOne
```

On-demand renewal override settings if not null

**Returns** `HasOne`

### overridingOnDemandRenewal

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

Override on-demand renewal settings

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `bool` | `$enable` |  |
| `int` | `$monthly` |  |
| `int` | `$quarterly` |  |
| `int` | `$semiannually` |  |
| `int` | `$annually` |  |
| `int` | `$biennially` |  |
| `int` | `$triennially` |  |


**Returns** `Addon`