ReactionProduct

ReactionProduct

Source:

ReactionProduct is only intended to be used on the client, but it's placed in common code because it is imported by the Products schema. ReactionProduct is a ReactiveDict, a general-purpose reactive datatype to use with Meteor Tracker. ReactionProduct allows the current product to be reactive, without Session.

Methods

(static) archiveProduct(productOrArray) → {undefined}

confirm to archive product

Source:
Parameters:
Name Type Description
productOrArray Object

product Object

Returns:
  • returns nothing, and alerts, happen here
Type
undefined

(static) checkChildVariants(parentVariantId) → {Number}

return number of child variants for a parent

Source:
Parameters:
Name Type Description
parentVariantId String

parentVariantId

Returns:

count of childVariants for this parentVariantId

Type
Number

(static) checkInventoryVariants(parentVariantId) → {Number}

return number of inventory variants for a parent

Source:
To Do:
  • could be combined with checkChildVariants in one method
  • inventoryVariants are deprecated. remove this.
Parameters:
Name Type Description
parentVariantId String

parentVariantId

Returns:

count of inventory variants for this parentVariantId

Type
Number

(static) cloneProduct(productOrArray) → {undefined}

product cloning and alert

Source:
Parameters:
Name Type Description
productOrArray Object | Array

if this method calls from productGrid it receives and array with product _id or _ids, but if it calls from PDP, when it receive a Object with _id. It needed to determine the source of call.

Returns:
  • returns nothing, and alerts, happen here
Type
undefined

(static) getProductsByTag(tag) → {Object}

method to return tag specific product

Source:
Parameters:
Name Type Description
tag String

tag string

Returns:
  • return products collection cursor filtered by tag
Type
Object

(static) getSiblings(variantopt, typeopt, includeSelfopt) → {Array}

Get all sibling variants - variants with the same ancestor tree could be useful for child variants relationships with top-level variants

Source:
Parameters:
Name Type Attributes Description
variant Object <optional>

product / variant object

type String <optional>

type of variant

includeSelf Boolean <optional>

include current variant in results

Returns:

Sibling variants or empty array

Type
Array

(static) getTopVariants(idopt) → {Array}

Get only product top level variants

Source:
Parameters:
Name Type Attributes Description
id String <optional>

product _id

Returns:

Product top level variants or empty array

Type
Array

(static) getVariantParent(variantopt) → {Array}

Get direct parent variant - could be useful for lower level variants to get direct parents

Source:
Parameters:
Name Type Attributes Description
variant Object <optional>

product / variant object

Returns:

Parent variant or empty

Type
Array

(static) getVariantQuantity(doc) → {Number}

middleware method which calls the same named common method.

Source:
To Do:
  • maybe we could remove this after 1.3. But for now I like how it looks.
Parameters:
Name Type Description
doc Object

variant object

Returns:

summary of options quantity or top-level variant inventoryQuantity

Type
Number

(static) getVariants(idopt, typeopt) → {Array}

Get all parent variants. Could be useful for products and for top level variants

Source:
Parameters:
Name Type Attributes Description
id String <optional>

product _id

type String <optional>

type of variant

Returns:

Parent variants or empty array

Type
Array

(static) isAncestorDeleted(product, includeSelf) → {Boolean}

Verify there are no deleted ancestors Variants cannot be restored if their parent product / variant is deleted

Source:
Parameters:
Name Type Description
product Object

product Object

includeSelf Boolean

include product

Returns:

True or false

Type
Boolean

(static) publishProduct(productOrArray) → {undefined}

product publishing and alert

Source:
To Do:
  • review process for publishing arrays of product
Parameters:
Name Type Description
productOrArray Object

product Object

Returns:
  • returns nothing, and alerts, happen here
Type
undefined

(static) ReactionProduct()

Reactive current product dependency, ensuring reactive products, without session ReactionProduct is a ReactiveDict, a general-purpose reactive datatype to use with Meteor Tracker.

Source:
See:
To Do:
  • this is a messy class implementation, normalize it.

(static) selectedProduct() → {Object|undefined}

get the currently active/requested product object

Source:
Returns:

currently selected product cursor

Type
Object | undefined

(static) selectedProductId() → {String}

get the currently active/requested product

Source:
Returns:

currently selected product id

Type
String

(static) selectedTopVariant() → {Object}

get the currently active TOP variant object

Source:
Returns:

currently selected TOP variant object

Type
Object

(static) selectedVariant() → {Object}

get the currently active/requested variant object

Source:
Returns:

currently selected variant object

Type
Object

(static) selectedVariantId() → {String}

get the currently active/requested variant

Source:
Returns:

currently selected variant id

Type
String

(static) setCurrentVariant(variantId) → {undefined}

Source:
Parameters:
Name Type Description
variantId String

set current variantId

Returns:
Type
undefined

(static) setProduct(currentProductId, currentVariantId) → {Object}

method to set default/parameterized product variant

Source:
To Do:
  • this will be deprecated in favor of template.instance data.
Parameters:
Name Type Description
currentProductId String

set current productId

currentVariantId String

set current variantId

Returns:

product object

Type
Object

(static) toggleVisibility(productOrArray) → {undefined}

product publishing and alert

Source:
Parameters:
Name Type Description
productOrArray Object

product Object

Returns:
  • returns nothing, and alerts, happen here
Type
undefined

(static) variantIsSelected(variantId) → {Boolean}

Source:
Parameters:
Name Type Description
variantId String

ID of variant to check

Returns:

True if variant is selected

Type
Boolean