# WHMCS\Product\Product

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

A product

A product represents a sellable item in WHMCS. The property object models a
product's properties and configuration. It stores billing, contact,
inventory, resource overage tracking, and 24 custom fields available to third
party modules.

Ordering a product creates a `WHMCS\Service\Service` object, which is
available for use by the client.

## Traits

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


## Constants

| Name | Description |
|  --- | --- |
| `TYPE_SHARED` |  |
| `TYPE_RESELLER` |  |
| `TYPE_SERVERS` |  |
| `TYPE_OTHER` |  |
| `PAYMENT_FREE` |  |
| `PAYMENT_ONETIME` |  |
| `PAYMENT_RECURRING` |  |
| `AUTO_SETUP_ORDER` |  |
| `AUTO_SETUP_PAYMENT` |  |
| `AUTO_SETUP_ACCEPT` |  |
| `AUTO_SETUP_DISABLED` |  |
| `DEFAULT_EMAIL_TEMPLATES` |  |


## Methods

### boot

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

### productGroup

```php
public function productGroup()
```

A product belongs to a product group.

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

### welcomeEmailTemplate

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

A product has one welcome email template.

**Returns** `HasOne`

### autoTerminationEmailTemplate

```php
public function autoTerminationEmailTemplate()
```

A product has one auto termination email template.

**Returns** `HasOne`

### upgradeEmailTemplate

```php
public function upgradeEmailTemplate()
```

A product has one upgrade email template.

**Returns** `HasOne`

### productDownloads

```php
public function productDownloads()
```

A product has many downloads.

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

### upgradeProducts

```php
public function upgradeProducts()
```

A product has many upgrade packages.

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

### services

```php
public function services()
```

A product can have many service instances of that product.

Services are what associate products with clients.

**Returns** `HasMany`

### customFields

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

**Returns** `HasMany`

### scopeVisible

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

Filter for only non-hidden products.

**Returns** `Builder`

### scopeSorted

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

Sort by display order.

**Returns** `Builder`

### getDownloadIds

```php
public function getDownloadIds()
```

Retrieve a list of the ids of the downloads associated with a product.

**Returns** `int[]`

### getUpgradeProductIds

```php
public function getUpgradeProductIds()
```

Retrieve a list of the ids of the upgrade products associated with a product.

**Returns** `int[]`

### getAvailableBillingCycles

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

Get available billing cycles for product.

**Returns** `string[]`

### pricing

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

Get available cycles and pricing for product.

**Parameters**

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


**Returns** `Pricing`

### getNameAttribute

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

Get the product 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 product 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`

### getTaglineAttribute

```php
public function getTaglineAttribute($tagline)
```

**Parameters**

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


**Returns** `string`

### getShortDescriptionAttribute

```php
public function getShortDescriptionAttribute($shortDescription)
```

**Parameters**

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


**Returns** `string`

### setShortDescriptionAttribute

```php
public function setShortDescriptionAttribute(string $shortDescription)
```

Set the products short description

**Parameters**

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


### translatedNames

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

Return the translated names for the specific product

**Returns** `HasMany\|\WHMCS\Language\DynamicTranslation[]`

### translatedDescriptions

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

Return the translated names for the specific product

**Returns** `HasMany\|\WHMCS\Language\DynamicTranslation[]`

### getProductName

```php
public static function getProductName($productId, $fallback = '', $language = null)
```

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

**Parameters**

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


**Returns** `string`

### getProductDescription

```php
public static function getProductDescription($productId, $fallback = '', $language = null)
```

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

**Parameters**

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


**Returns** `string`

### assignMatchingMarketConnectAddons

```php
public function assignMatchingMarketConnectAddons(array $addons)
```

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Addon[]` | `$addons` |  |


### 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`

### scopeIsNotRetired

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

**Parameters**

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


**Returns** `Builder`

### scopeIsRetired

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

**Parameters**

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


**Returns** `Builder`

### scopeOfModule

```php
public function scopeOfModule(Builder $query, string $module): Builder
```

### getProductKeyAttribute

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

Get product key attribute for the current product entity.

**Parameters**

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


**Returns** `string`

### isMarketConnectProduct

```php
public function isMarketConnectProduct()
```

Is this a MarketConnect product?

**Returns** `bool`

### getServiceKeyAttribute

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

Get service key attribute for the current product entity.

**Parameters**

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


**Returns** `string`

### isValidForUpgrade

```php
public function isValidForUpgrade(Product $product)
```

Validate a given product is a valid upgrade candidate.

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Product` | `$product` |  |


**Returns** `bool`

### getFormattedProductFeaturesAttribute

```php
public function getFormattedProductFeaturesAttribute()
```

**Returns** `array`

### getBilledMetricsAttribute

```php
public function getBilledMetricsAttribute()
```

### metrics

```php
public function metrics()
```

**Returns** `HasMany`

### enabledMetrics

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

Usage metrics that are enabled

**Returns** `HasMany`

### recommendations

```php
public function recommendations(): BelongsToMany
```

**Returns** `BelongsToMany`

### recommendationExists

```php
public function recommendationExists(int $productId): bool
```

### emailMarketerRules

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

### getClientStockLevel

```php
public function getClientStockLevel(): int
```

**Returns** `int`

### moduleConfiguration

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

**Returns** `HasMany`

### getModuleConfigurationSetting

```php
public function getModuleConfigurationSetting(string $settingName): ModuleConfiguration
```

### eventActions

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

**Returns** `HasMany`

### duplicate

```php
public function duplicate(string $newProductName): Product
```

Duplicate a Product along with all corresponding attributes

**Parameters**

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


**Returns** `Product` — New Duplicated Product

### slugs

```php
public function slugs(): Relation
```

**Returns** `HasMany`

### inactiveSlugs

```php
public function inactiveSlugs(): Relation
```

**Returns** `HasMany`

### activeSlug

```php
public function activeSlug(): Relation
```

**Returns** `HasOne`

### validateSlugIsUnique

```php
public function validateSlugIsUnique(string $slug): bool
```

**Parameters**

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


**Returns** `bool`

### getExistingSlugCheck

```php
public function getExistingSlugCheck(string $slug): Builder
```

### createSlug

```php
public function createSlug()
```

### getRoutePath

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

### getRecommendationRoutePath

```php
public function getRecommendationRoutePath(?int $productId = null): string
```

### getRouteParts

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

### 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** `Product`