Commerce
Module to generate commerce and product related entries.
Overview
For a long product name like 'Incredible Soft Gloves'
, use productName()
. The product names are generated from a list of adjectives, materials, and products, which can each be accessed separately using productAdjective()
, productMaterial()
, and product()
. You can also create a description using productDescription()
.
For a department in a shop or product category, use department()
.
You can also create a price using price()
.
department
Returns a department inside a shop.
Available since v3.0.0
Returns: string
faker.commerce.department(): string
faker.commerce.department() // => "Toys"
faker.commerce.department() // 'Garden'
Source
price
Generates a price between min and max (inclusive).
Available since v3.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options? | number | { ... } | {} | The minimum price or on options object. |
options.dec? | number | 2 | The number of decimal places. |
options.max? | number | 1000 | The maximum price. |
options.min? | number | 1 | The minimum price. |
options.symbol? | string | '' | The currency value to use. |
legacyMax? | number | 1000 | The maximum price. This argument is deprecated. |
legacyDec? | number | 2 | The number of decimal places. This argument is deprecated. |
legacySymbol? | string | '' | The currency value to use. This argument is deprecated. |
Returns: string
faker.commerce.price(options?: number | {
dec: number,
max: number,
min: number,
symbol: string
} = {}, legacyMax?: number = 1000, legacyDec?: number = 2, legacySymbol?: string = ''): string
faker.commerce.price() // => "549.00"
faker.commerce.price() // 828.00
faker.commerce.price({ min: 100 }) // 904.00
faker.commerce.price({ min: 100, max: 200 }) // 154.00
faker.commerce.price({ min: 100, max: 200, dec: 0 }) // 133
faker.commerce.price({ min: 100, max: 200, dec: 0, symbol: '$' }) // $114
Source
product
Returns a short product name.
Available since v3.0.0
Returns: string
faker.commerce.product(): string
faker.commerce.product() // => "Towels"
faker.commerce.product() // 'Computer'
Source
productAdjective
Returns an adjective describing a product.
Available since v3.0.0
Returns: string
faker.commerce.productAdjective(): string
faker.commerce.productAdjective() // => "Bespoke"
faker.commerce.productAdjective() // 'Handcrafted'
Source
productDescription
Returns a product description.
Available since v5.0.0
Returns: string
faker.commerce.productDescription(): string
faker.commerce.productDescription() // => "The Football Is Good For Training And Recreati...
faker.commerce.productDescription() // 'Andy shoes are designed to keeping...'
Source
productMaterial
Returns a material of a product.
Available since v3.0.0
Returns: string
faker.commerce.productMaterial(): string
faker.commerce.productMaterial() // => "Granite"
faker.commerce.productMaterial() // 'Rubber'
Source
productName
Generates a random descriptive product name.
Available since v3.0.0
Returns: string
faker.commerce.productName(): string
faker.commerce.productName() // => "Bespoke Rubber Fish"
faker.commerce.productName() // 'Incredible Soft Gloves'