Product
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.
Constants
TYPE_SHARED |
|
TYPE_RESELLER |
|
TYPE_SERVERS |
|
TYPE_OTHER |
|
PAYMENT_FREE |
|
PAYMENT_ONETIME |
|
PAYMENT_RECURRING |
|
Properties summary
Type | Property | Description | |
---|---|---|---|
protected | $table | ||
protected | $columnMap | ||
protected | $booleans | ||
protected | $strings | ||
protected | $ints | ||
protected | $commaSeparated | ||
int | $id | A product's unique id number. | |
string | $type | A product's type, either "hostingaccount", "reselleraccount", "server", or "other". | |
int | $productGroupId | The id of group a product belongs to. | |
string | $name | A product's name. | |
string | $description | A product's description. Some order form templates may render structured data in a product's description. | |
bool | $isHidden | Whether or not to display a product in shopping cart modules. | |
bool | $showDomainOptions | Whether or not the shopping cart should require a domain be purchased, transferred, or supplied (if already owned) to a product. | |
int | $welcomeEmailTemplateId | ID number of welcome email template sent to customers when this product is activated. | |
bool | $stockControlEnabled | Whether or not a product has limited stock which must be monitored. | |
int | $quantityInStock | A product's currently available quantity, if stock control is enabled. | |
bool | $proRataBilling | Whether or not a product uses pro rata billing instead of standard month-to-month | |
int | $proRataChargeDayOfCurrentMonth | The day of the month upon which pro rata billing should charge on. | |
int | $proRataChargeNextMonthAfterDay | The day of the month after which the following month will also be included on the first invoice. | |
string | $paymentType | A product's payment type, either "recurring", "onetime", or "free". | |
int | $allowMultipleQuantities | Whether or not customers may specify if they want more than one of this item when purchasing. | |
string[] | $freeSubDomains | The domains a client can select for a free sub-domain. | |
string | $autoSetup | When provisioning a product should take place, either "order", "payment", "on", or "". | |
string | $module | The name of the module used to provision a product. | |
int | $serverGroupId | The id number of server group a product should be provisioned to. | |
string | $moduleConfigOption1 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption2 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption3 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption4 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption5 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption6 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption7 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption8 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption9 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption10 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption11 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption12 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption13 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption14 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption15 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption16 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption17 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption18 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption19 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption20 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption21 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption22 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption23 | Modules may use this field to store module specific configuration. | |
string | $moduleConfigOption24 | Modules may use this field to store module specific configuration. | |
string | $freeDomain | Whether purchasing a product provisions a free domain name, either "once", "on", or "". | |
string[] | $freeDomainPaymentTerms | The payment terms a product must be purchased with to be provisioned with a free domain name, anything from the set "onetime", "monthly", "quarterly", "semiannually", "annually", "biennially", and "triennially". | |
string[] | $freeDomainTlds | The top-level domains that are available for use with a product's free domain. | |
int | $recurringCycleLimit | The number of billing cycles a product may automatically renew. | |
int | $daysAfterSignUpUntilAutoTermination | The number of days after sign up before a product is automatically terminated. | |
int | $autoTerminationEmailTemplateId | The id of the email to send to a client when a product is automatically terminated. | |
bool | $allowConfigOptionUpgradeDowngrade | Whether or not a product's configurable options can be upgraded and downgraded. | |
int | $upgradeEmailTemplateId | The id of the email to send to a client when a product's options are upgraded. | |
array | $enableOverageBillingAndUnits | An array whose first value is true if overages are enabled. Its second value is the unit to use for a product's disk usage limits, either "MB", "GB", or "TB". Its third value is the unit to use for a product's bandwidth usage limits, either "MB", "GB", or "TB". | |
int | $overageDiskLimit | The soft limit of a product's allowed disk usage to this number of units configured in enableOverageBillingAndUnits. | |
int | $overageBandwidthLimit | The soft limit of a product's allowed bandwidth usage to this number of units configured in enableOverageBillingAndUnits. | |
float | $overageDiskPrice | The price to charge per unit configured in enableOverageBillingAndUnits for a product's disk usage above the soft limit configured in overageDiskLimit. | |
float | $overageBandwidthPrice | The price to charge per unit configured in enableOverageBillingAndUnits for a product's bandwidth usage above the soft limit configured in overageBandwidthLimit. | |
bool | $applyTax | Whether or not tax should be applied to a product. | |
bool | $affiliatePayoutOnceOnly | Whether or not affiliates should only be paid on a product once, even if it's a recurring product. | |
string | $affiliatePaymentType | The type of payment available for affiliates that successfully promote a product, either "percentage", "fixed", "none", or "" (the default payout method). | |
float | $affiliatePaymentAmount | The percent or fixed amount which should be paid to affiliates. | |
int | $displayOrder | The order in which to display a product in its group. | |
bool | $isRetired | Whether or not a product is retired and should no longer be sold. | |
bool | $isFeatured | Whether or not a product is displayed more prominently in its product group. | |
Carbon | $createdAt | The date a product was created. | |
Carbon | $updatedAt | The date a product was last updated. | |
Group | $productGroup | The group a product belongs to. | |
Template | $welcomeEmailTemplate | The email to send to a client when a product is ordered. | |
Template | $autoTerminationEmailTemplate | The email to send to a client when a product is automatically terminated. | |
Template | $upgradeEmailTemplate | The email to send to a client when a product's options are upgraded. | |
Collection|Download[] | $productDownloads | A product's associated downloadable files. | |
Collection|Product[] | $upgradeProducts | Products which a product can be upgraded or downgraded to. | |
Collection|Service[] | $services | The services provisioned from a product. | |
Collection|CustomField[] | $customFields | The custom fields for a product. | |
Collection|DynamicTranslation[] | $translatedNames | ||
Collection|DynamicTranslation[] | $translatedDescriptions |
Methods summary
Return Type | Method Name | Description | |
---|---|---|---|
static | boot() | - | |
BelongsTo | productGroup() | A product belongs to a product group. | |
HasOne | welcomeEmailTemplate() | A product has one welcome email template. | |
HasOne | autoTerminationEmailTemplate() | A product has one auto termination email template. | |
HasOne | upgradeEmailTemplate() | A product has one upgrade email template. | |
BelongsToMany | productDownloads() | A product has many downloads. | |
BelongsToMany | upgradeProducts() | A product has many upgrade packages. | |
HasMany | services() | A product can have many service instances of that product. | |
HasMany | customFields() | - | |
Builder | scopeVisible(Builder $query) | Filter for only non-hidden products. | |
Builder | scopeSorted($query) | Sort by display order. | |
int[] | getDownloadIds() deprecated | Retrieve a list of the ids of the downloads associated with a product. | |
int[] | getUpgradeProductIds() deprecated | Retrieve a list of the ids of the upgrade products associated with a product. | |
string[] | getAvailableBillingCycles() | Get available billing cycles for product. | |
string[] | pricing(array|null $currency = null) | Get available cycles and pricing for product. | |
string | getNameAttribute(string $name) | Get the product name - this will override the output from the db value if set in Lang. | |
string | getDescriptionAttribute(string $description) | Get the product description - this will override the output from the db value if set in Lang. | |
HasMany|DynamicTranslation[] | translatedNames() | Return the translated names for the specific product | |
HasMany|DynamicTranslation[] | translatedDescriptions() | Return the translated names for the specific product | |
static string | getProductName(int $productId, string $fallback = '', string $language = null) | Obtain the product name for the current language, passed language or fallback to the currently defined value for the product. | |
static string | getProductDescription(int $productId, string $fallback = '', string $language = null) | Obtain the product description for the current language, passed language or fallback to the currently defined value for the product. | |
assignMatchingMarketConnectAddons(array $addons) | - | ||
bool | isFree() | Is product a free product. | |
bool | isOneTime() | Is product a one time product. | |
Builder | scopeMarketConnect(Builder $query) | Quick filter for module = marketconnect. | |
scopeSsl(Builder $query) | The following are scope helpers for MarketConnect products. | ||
scopeRapidssl(Builder $query) | - | ||
scopeGeotrust(Builder $query) | - | ||
scopeSymantec(Builder $query) | - | ||
scopeWeebly(Builder $query) | - | ||
scopeSpamexperts(Builder $query) | - | ||
scopeSitelock(Builder $query) | - | ||
scopeMarketConnectProducts(Builder $query, $products) | - | ||
Builder | scopeProductKey(Builder $query, string $productKey) | Quick filter for a given MarketConnect product key. | |
string | getProductKeyAttribute(string $value) | Get product key attribute for the current product entity. | |
bool | isMarketConnectProduct() | Is this a MarketConnect product? | |
string | getServiceKeyAttribute(string $value) | Get service key attribute for the current product entity. | |
bool | isValidForUpgrade(Product $product) | Validate a given product is a valid upgrade candidate. |
Details
static
boot ()
BelongsTo
productGroup ()
A product belongs to a product group.
HasOne
welcomeEmailTemplate ()
A product has one welcome email template.
HasOne
autoTerminationEmailTemplate ()
A product has one auto termination email template.
HasOne
upgradeEmailTemplate ()
A product has one upgrade email template.
BelongsToMany
productDownloads ()
A product has many downloads.
BelongsToMany
upgradeProducts ()
A product has many upgrade packages.
HasMany
services ()
A product can have many service instances of that product.
Services are what associate products with clients.
HasMany
customFields ()
Builder
scopeVisible (Builder $query)
Filter for only non-hidden products.
Builder
scopeSorted ($query)
Sort by display order.
int[]
getDownloadIds ()
deprecated
deprecated
Retrieve a list of the ids of the downloads associated with a product.
int[]
getUpgradeProductIds ()
deprecated
deprecated
Retrieve a list of the ids of the upgrade products associated with a product.
string[]
getAvailableBillingCycles ()
Get available billing cycles for product.
string[]
pricing (array|null $currency = null)
Get available cycles and pricing for product.
string
getNameAttribute (string $name)
Get the product name - this will override the output from the db value if set in Lang.
string
getDescriptionAttribute (string $description)
Get the product description - this will override the output from the db value if set in Lang.
HasMany|DynamicTranslation[]
translatedNames ()
Return the translated names for the specific product
HasMany|DynamicTranslation[]
translatedDescriptions ()
Return the translated names for the specific product
static string
getProductName (int $productId, string $fallback = '', string $language = null)
Obtain the product name for the current language, passed language or fallback to the currently defined value for the product.
static string
getProductDescription (int $productId, string $fallback = '', string $language = null)
Obtain the product description for the current language, passed language or fallback to the currently defined value for the product.
assignMatchingMarketConnectAddons (array $addons)
bool
isFree ()
Is product a free product.
bool
isOneTime ()
Is product a one time product.
Builder
scopeMarketConnect (Builder $query)
Quick filter for module = marketconnect.
scopeSsl (Builder $query)
The following are scope helpers for MarketConnect products.
scopeRapidssl (Builder $query)
scopeGeotrust (Builder $query)
scopeSymantec (Builder $query)
scopeWeebly (Builder $query)
scopeSpamexperts (Builder $query)
scopeSitelock (Builder $query)
scopeMarketConnectProducts (Builder $query, $products)
Builder
scopeProductKey (Builder $query, string $productKey)
Quick filter for a given MarketConnect product key.
string
getProductKeyAttribute (string $value)
Get product key attribute for the current product entity.
bool
isMarketConnectProduct ()
Is this a MarketConnect product?
string
getServiceKeyAttribute (string $value)
Get service key attribute for the current product entity.
bool
isValidForUpgrade (Product $product)
Validate a given product is a valid upgrade candidate.
For MarketConnect, validates upgrade product service key matches current product key.