product
x5engine.cart.product
Kind: global class
Summary: Describe a product method. Usually you don't want to directly instantiate this class but rather access to the instances created by WSX5 and stored in `x5engine.cart.manager`.
You may get them using `x5engine.cart.manager.store()`.
- product
- new product(productData, settings)
- .base() ⇒
Object
- .quiet(q) ⇒
Boolean
- .id() ⇒
String
- .quantity(n) ⇒
Number
- .availableOrThrow() ⇒
Void
- .option(id) ⇒
String
- .subOption(id) ⇒
String
- .discount(includeVat) ⇒
Number
- .singleFullPrice(includeVat) ⇒
Number
- .singlePrice(includeVat) ⇒
Number
- .fullPrice(includeVat) ⇒
Number
- .price(includeVat) ⇒
Number
- .singleVat(includeVat) ⇒
Number
- .fullVat() ⇒
Number
- .vat() ⇒
Number
- .weight() ⇒
Number
- .enableCoupon() ⇒
Boolean
- .disableCoupon() ⇒
Boolean
new product(productData, settings)
Create a new Product object.
Param | Type | Description |
---|---|---|
productData | Object |
The generic product data |
productData.id | String |
Software internal product id |
productData.id_user | String |
Product id set by the user |
productData.category | String |
The Category ID |
productData.description | String |
The product description |
productData.price | Number |
The product price as a pure number |
productData.images | Array |
The images URLs array |
productData.link | String |
The link URL to place over the product image |
productData.vat | Number |
The VAT amount |
productData.vattype | String |
The VAT type. Default "none". |
productData.weight | Number |
The product's weight as a pure number |
productData.availabilityType | String |
The produt's availability type: "fixed" or "dynamic" |
productData.staticAvailValue | String |
The produt's static availability value. Default "unknown". |
productData.precision | Number |
The price's precision |
productData.minQuantity | Number |
The minimum quantity that should be ordered to make a valid order |
productData.options | Object |
The product's variations (options). This object contains the options ids as keys and the options data as values |
productData.options.id.name | String |
The variation name |
productData.options.id.suboptions | Array |
The array of strings with a list of the available sub options |
productData.options.id.weightvar | Number |
The weight variation for this option |
productData.options.id.pricevar | Number |
The price variation for this option |
productData.discount | Object |
The discount object |
productData.discount.coupon | String |
The discount coupon |
productData.discount.type | String |
The discount type: "relative" (percentual) or "absolute" |
productData.discount.amount | String |
The discount amount in percentual (0-1) if type is "relative" or as a pure number if type is "absolute" |
productData.discount.coupon_start_date | String |
The coupon's first day of validity |
productData.discount.coupon_end_date | String |
The coupon's last day of validity |
productData.quantityDiscounts | Object |
The product's quantity discounts. Each key is a quantity, each value the discount for the given minimum quantity |
settings | Object |
The instance settings like option, suboption, quantity etc |
settings.quantity | Object |
The number of products |
settings.option | Object |
The selected option id. Can be null. |
settings.suboption | Object |
The selected suboption id. Can be null. |
.base() ⇒ Object
Provide the product settings
Kind: instance method of product
.quiet(q) ⇒ Boolean
Enable or disable the quiet status for this product.
Kind: instance method of product
Returns: Boolean
- The current value
Since: 12.0.0
Param | Type | Description |
---|---|---|
q | Boolean |
If false, adding a quantity higher than the amount of stored items will throw an exception. |
.id() ⇒ String
Provide the product id
Kind: instance method of product
.quantity(n) ⇒ Number
Get or set the current quantity
Kind: instance method of product
Returns: Number
- The current quantity
Param | Type | Description |
---|---|---|
n | Number |
The quantity |
.availableOrThrow() ⇒ Void
Does nothing if the product is available or throw an error if the product is not available.
Available only in the Professional Edition.
Kind: instance method of product
Since: 12.0.0
.option(id) ⇒ String
Get/Set the current option id
Kind: instance method of product
Returns: String
- Option id
Param | Type | Description |
---|---|---|
id | String |
Option id |
.subOption(id) ⇒ String
Get/Set the current suboption id
Kind: instance method of product
Returns: String
- SubOption id
Param | Type | Description |
---|---|---|
id | Number |
Suboption id |
.discount(includeVat) ⇒ Number
Provide the current discount
Kind: instance method of product
Param | Type | Description |
---|---|---|
includeVat | Boolean |
True to include VAT |
.singleFullPrice(includeVat) ⇒ Number
Get the single price without discount
Kind: instance method of product
Param | Type | Description |
---|---|---|
includeVat | Boolean |
True to include VAT |
.singlePrice(includeVat) ⇒ Number
Get the single element price
Kind: instance method of product
Param | Type | Description |
---|---|---|
includeVat | Boolean |
True to include VAT |
.fullPrice(includeVat) ⇒ Number
Get the current price without discount
Kind: instance method of product
Param | Type | Description |
---|---|---|
includeVat | Boolean |
True to include VAT |
.price(includeVat) ⇒ Number
Provide the current price with discount
Kind: instance method of product
Param | Type | Description |
---|---|---|
includeVat | Boolean |
True to include VAT |
.singleVat(includeVat) ⇒ Number
Provide the vat for a single product
Kind: instance method of product
Param | Type | Description |
---|---|---|
includeVat | Boolean |
True to include VAT |
.fullVat() ⇒ Number
Provide the VAT without discounts
Kind: instance method of product
.vat() ⇒ Number
Provide the VAT
Kind: instance method of product
.weight() ⇒ Number
Get the weight of this object
Kind: instance method of product
.enableCoupon() ⇒ Boolean
Activate the coupon discount
Kind: instance method of product
.disableCoupon() ⇒ Boolean
Disable the coupon activation
Kind: instance method of product