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.
BillingTraitMarketConnectTraitOnDemandRenewalTraitSlugTrait
| 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 |
public static function boot()public function productGroup()A product belongs to a product group.
Returns \Illuminate\Database\Eloquent\Relations\BelongsTo
public function welcomeEmailTemplate()A product has one welcome email template.
Returns HasOne
public function autoTerminationEmailTemplate()A product has one auto termination email template.
Returns HasOne
public function upgradeEmailTemplate()A product has one upgrade email template.
Returns HasOne
public function productDownloads()A product has many downloads.
Returns \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function upgradeProducts()A product has many upgrade packages.
Returns \Illuminate\Database\Eloquent\Relations\BelongsToMany
public function services()A product can have many service instances of that product.
Services are what associate products with clients.
Returns HasMany
public function customFields()Returns HasMany
public function scopeVisible(Builder $query)Filter for only non-hidden products.
Returns Builder
public function scopeSorted($query)Sort by display order.
Returns Builder
public function getDownloadIds()Retrieve a list of the ids of the downloads associated with a product.
Returns int[]
public function getUpgradeProductIds()Retrieve a list of the ids of the upgrade products associated with a product.
Returns int[]
public function getAvailableBillingCycles(): arrayGet available billing cycles for product.
Returns string[]
public function pricing($currency = null): PricingGet available cycles and pricing for product.
Parameters
| Type | Name | Description |
|---|---|---|
array|null | $currency | Only required on first call. |
Returns Pricing
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
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
public function getTaglineAttribute($tagline)Parameters
| Type | Name | Description |
|---|---|---|
string | $tagline |
Returns string
public function getShortDescriptionAttribute($shortDescription)Parameters
| Type | Name | Description |
|---|---|---|
string | $shortDescription |
Returns string
public function setShortDescriptionAttribute(string $shortDescription)Set the products short description
Parameters
| Type | Name | Description |
|---|---|---|
string | $shortDescription |
public function translatedNames()Return the translated names for the specific product
Returns HasMany\|\WHMCS\Language\DynamicTranslation[]
public function translatedDescriptions()Return the translated names for the specific product
Returns HasMany\|\WHMCS\Language\DynamicTranslation[]
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
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
public function assignMatchingMarketConnectAddons(array $addons)Parameters
| Type | Name | Description |
|---|---|---|
Addon[] | $addons |
public function isFree(): boolIs product a free product.
Returns bool
public function isOneTime(): boolIs product a one time product.
Returns bool
public function scopeIsNotRetired(Builder $query)Parameters
| Type | Name | Description |
|---|---|---|
Builder | $query |
Returns Builder
public function scopeIsRetired(Builder $query)Parameters
| Type | Name | Description |
|---|---|---|
Builder | $query |
Returns Builder
public function scopeOfModule(Builder $query, string $module): Builderpublic function getProductKeyAttribute()Get product key attribute for the current product entity.
Parameters
| Type | Name | Description |
|---|---|---|
string | $value |
Returns string
public function isMarketConnectProduct()Is this a MarketConnect product?
Returns bool
public function getServiceKeyAttribute($value)Get service key attribute for the current product entity.
Parameters
| Type | Name | Description |
|---|---|---|
string | $value |
Returns string
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
public function getFormattedProductFeaturesAttribute()Returns array
public function getBilledMetricsAttribute()public function metrics()Returns HasMany
public function enabledMetrics(): HasManyUsage metrics that are enabled
Returns HasMany
public function recommendations(): BelongsToManyReturns BelongsToMany
public function recommendationExists(int $productId): boolpublic function emailMarketerRules()public function getClientStockLevel(): intReturns int
public function moduleConfiguration()Returns HasMany
public function getModuleConfigurationSetting(string $settingName): ModuleConfigurationpublic function eventActions(): HasManyReturns HasMany
public function duplicate(string $newProductName): ProductDuplicate a Product along with all corresponding attributes
Parameters
| Type | Name | Description |
|---|---|---|
string | $newProductName |
Returns Product — New Duplicated Product
public function slugs(): RelationReturns HasMany
public function inactiveSlugs(): RelationReturns HasMany
public function activeSlug(): RelationReturns HasOne
public function validateSlugIsUnique(string $slug): boolParameters
| Type | Name | Description |
|---|---|---|
string | $slug |
Returns bool
public function getExistingSlugCheck(string $slug): Builderpublic function createSlug()public function getRoutePath(): stringpublic function getRecommendationRoutePath(?int $productId = null): stringpublic function getRouteParts(): arraypublic function getOrderLineItemProductGroupName(): stringpublic function overrideOnDemandRenewal(): HasOneOn-demand renewal override settings if not null
Returns HasOne
public function overridingOnDemandRenewal(bool $enable, int $monthly, int $quarterly, int $semiannually, int $annually, int $biennially, int $triennially): selfOverride on-demand renewal settings
Parameters
| Type | Name | Description |
|---|---|---|
bool | $enable | |
int | $monthly | |
int | $quarterly | |
int | $semiannually | |
int | $annually | |
int | $biennially | |
int | $triennially |
Returns Product