Core

Core

Methods

(static) addRolesToGroups(options) → {Number}

Add roles to the default groups for shops and updates any users that are in those permission groups Options: allShops: add supplied roles to all shops, defaults to false roles: Array of roles to add to default roles set shops: Array of shopIds that should be added to set groups: Groups to add roles to, Options: ["guest", "customer", "owner"]

Source:
Parameters:
Name Type Description
options Object

See above for details

Returns:

result of Groups.update method (number of documents updated)

Type
Number

(static) assignOwnerRoles(shopId, pkgName, registry) → {undefined}

populate roles with all the packages and their permissions this is the main way that roles are inserted and created for admin user. we assign all package roles to each owner account for each shopId we assign only basic GLOBAL_GROUP rights

Source:
Parameters:
Name Type Description
shopId String

shopId

pkgName String

Package name

registry String

registry object

Returns:
Type
undefined

(static) canInviteToGroup(options) → {Boolean}

checks if the user making the request is allowed to make invitation to that group

Source:
Parameters:
Name Type Description
options Object

-

Properties
Name Type Description
group Object

group to invite to

user Object

user object making the invite (Meteor.user())

Returns:

-

Type
Boolean

(static) clearCache() → {undefined}

allows the client to trigger an uncached lookup of the shopId. this is useful when a user switches shops.

Source:
Returns:
Type
undefined

(static) createDefaultAdminUser() → {String}

Method that creates default admin user Settings load precendence:

  1. environment variables
  2. settings in meteor.settings

Source:
Returns:

return userId

Type
String

(static) createGroups(options) → {null}

creates groups for shops

Source:
Parameters:
Name Type Description
options object

-

Properties
Name Type Description
shopId string

the id of shop to create the group for. Not passing a shopId creates the group(s) for all available shops

roles object

key-value pair representing the group slug (key) and array of roles for the group (value)

Returns:
Type
null

(static) getAppVersion() → {String}

Source:
Returns:

App version

Type
String

(static) getCartShopId() → {StringId}

Get the correct shop ID to use for Cart collection

Source:
Returns:

The primary or current shop ID, depending on merchantCart setting

Type
StringId

(static) getCartShopId() → {StringId}

Get the correct shop ID to use for Cart collection

Source:
Returns:

The primary or current shop ID, depending on merchantCart setting

Type
StringId

(static) getCurrentShop() → {Object}

DEPRECATED This method has been deprecated in favor of using getShopId and getPrimaryShopId. To be removed.

Source:
Deprecated:
  • Yes
Returns:

returns the first shop object from the shop cursor

Type
Object

(static) getCurrentShopCursor() → {Cursor}

DEPRECATED This method has been deprecated in favor of using getShopId and getPrimaryShopId. To be removed.

Source:
Deprecated:
  • Yes
Returns:

cursor of shops that match the current domain

Type
Cursor

(static) getDomain() → {String}

Get shop domain for URL

Source:
Returns:

Shop domain

Type
String

(static) getMarketplaceSettings() → {Object}

finds the enabled reaction-marketplace package for the primary shop and returns the settings

Source:
Returns:

The marketplace settings from the primary shop or undefined

Type
Object

(static) getPackageSettings(name) → {Object|null}

Get package settings

Source:
Parameters:
Name Type Description
name String

Package name

Returns:

Package setting object or null

Type
Object | null

(static) getPackageSettingsWithOptions(options) → {object}

Takes options in the form of a query object. Returns a package that matches.

Source:
Parameters:
Name Type Description
options object

Options object, forms the query for Packages.findOne

Returns:

Returns the first package found with the provided options

Type
object

(static) getPrimaryShop() → {Object}

Get the first created shop. In marketplace, the Primary Shop is the shop that controls the marketplace and can see all other shops

Source:
Returns:

Shop

Type
Object

(static) getPrimaryShopCurrency() → {String}

Get primary shop currency string

Source:
Returns:

Get shop currency or "USD"

Type
String

(static) getPrimaryShopId() → {String}

Get the first created shop ID. In marketplace, the Primary Shop is the shop that controls the marketplace and can see all other shops

Source:
Returns:

ID

Type
String

(static) getPrimaryShopName() → {String}

Get primary shop name or empty string

Source:
Returns:

Return shop name or empty string

Type
String

(static) getPrimaryShopPrefix() → {String}

Get primary shop prefix for URL

Source:
To Do:
  • Primary Shop should probably not have a prefix (or should it be /shop?)
Returns:

Prefix in the format of "/"

Type
String

(static) getPrimaryShopSettings() → {Object}

Get primary shop settings object

Source:
Returns:

Get settings object or empty object

Type
Object

(static) getRegistryDomain(requestUrl) → {String}

local helper for creating admin users

Source:
Parameters:
Name Type Description
requestUrl String

url

Returns:

domain name stripped from requestUrl

Type
String

(static) getSeller(shopId) → {Object}

Source:
Example
Reaction.getSeller(shopId)
Parameters:
Name Type Description
shopId String

ID of shop

Returns:

Account object of seller

Type
Object

(static) getSellerShop(user, noFallbackopt) → {String|Boolean}

Get a seller's shop or default to parent shop

Source:
Parameters:
Name Type Attributes Default Description
user String | Object

An optional user hash or userId to find a shop for

noFallback Boolean <optional>
false

Optional.If set to true doesn't fallback to owner shop when user doesn't have a shop.

Returns:
  • The shop hash belonging to userId, or loggedIn seller, or the parent shop
Type
String | Boolean

(static) getSellerShopId(user, noFallbackopt) → {String|Boolean}

Get a seller's shopId or default to parent shopId

Source:
Example
Reaction.getSellerShopId(this.userId, true)
Parameters:
Name Type Attributes Default Description
user String | Object

An optional user hash or userId to find a shop for

noFallback Boolean <optional>
false

Optional.If set to true doesn't fallback to owner shopId when user doesn't have a shop.

Returns:
  • The shopId belonging to userId, or loggedIn seller, or the parent shopId
Type
String | Boolean

(static) getSellerShopId() → {String}

Source:
Returns:

Shop ID

Type
String

(static) getShopCurrencies() → {Object}

Get all currencies available to a shop

Source:
Returns:

Shop currency or "USD"

Type
Object

(static) getShopCurrency() → {String}

Get shop currency

Source:
Returns:

Shop currency or "USD"

Type
String

(static) getShopEmail() → {String}

Get shop email

Source:
Returns:

String with the first store email

Type
String

(static) getShopId() → {String}

Get shop ID, first by checking the current user's preferences then by getting the shop by the current domain.

Source:
To Do:
  • should we return the Primary Shop if none found?
Returns:

active shop ID

Type
String

(static) getShopIdByDomain() → {StringId}

searches for a shop which should be used given the current domain

Source:
Returns:

shopId

Type
StringId

(static) getShopLanguage() → {String}

Source:
To Do:
  • TODO: Marketplace - should each shop set their own default language or should the Marketplace set a language that's picked up by all shops?
Returns:

language

Type
String

(static) getShopName() → {String}

If we can't find the shop or shop name return an empty string

Source:
Returns:

Shop name or empty string ""

Type
String

(static) getShopPrefix() → {String}

Get shop prefix for URL

Source:
Returns:

String in the format of "/shop/slug"

Type
String

(static) getShopSettings(nameopt) → {Object}

Get shop settings object

Source:
Parameters:
Name Type Attributes Default Description
name String <optional>
"core"

Package name

Returns:

Shop settings object or empty object

Type
Object

(static) getShopsWithRoles(roles, userId) → {array}

Finds all shops that a user has a given set of roles for

Source:
Parameters:
Name Type Description
roles array

an array of roles to check. Will return a shopId if the user has any of the roles

userId string

Optional userId, defaults to logged in userId Must pass this.userId from publications to avoid error!

Returns:

Array of shopIds that the user has at least one of the given set of roles for

Type
array

(static) getTagIds(state) → {Array}

Get an array of IDs of tags

Source:
Example
getTagIds({ tags: subTagGroups })
Parameters:
Name Type Description
state Object

object

Properties
Name Type Description
tags Array

Array of tags

Returns:

Array of tag IDs

Type
Array

(static) getUserPreferences(options) → {String|undefined}

Source:
Parameters:
Name Type Description
options Object

{packageName, preference, defaultValue}

Returns:

User's package preference or undefined

Type
String | undefined

(static) getUserShopId(userId) → {StringId}

Get a user's shop ID, as stored in preferences

Source:
To Do:
  • This should intelligently find the correct default shop Probably whatever the main shop is or marketplace
Parameters:
Name Type Description
userId String

(probably logged in userId)

Returns:

active shop ID

Type
StringId

(static) getVariantIds(variants) → {Array}

Get array of IDs of variants

Source:
Example
getVariantIds(newVariantOrder)
Parameters:
Name Type Description
variants Array

Array of variant objects

Returns:

Array of variant object IDs

Type
Array

(static) hasAdminAccess() → {Boolean}

Source:
Returns:

Boolean - true if has permission

Type
Boolean

(static) hasDashboardAccess() → {Boolean}

Source:
Returns:

Boolean - true if has permission

Type
Boolean

(static) hasOwnerAccess() → {Boolean}

Source:
Returns:

Boolean - true if has permission

Type
Boolean

(static) hasPermission(checkPermissions, userId, checkGroup) → {Boolean}

server permissions checks hasPermission exists on both the server and the client.

Source:
Parameters:
Name Type Description
checkPermissions String | Array

String or Array of permissions if empty, defaults to "admin, owner"

userId String

userId, defaults to logged in userId

checkGroup String

group - default to shopId

Returns:

Boolean - true if has permission

Type
Boolean

(static) html(strings) → {String}

Template literal for HTML strings.

Source:
Parameters:
Name Type Description
strings Object

Object of strings

Returns:

string

Type
String

(static) insertPackagesForShop(shopId) → {String}

insert Reaction packages into Packages collection registry for a new shop

  • Assigns owner roles for new packages
  • Imports layouts from packages

Source:
Parameters:
Name Type Description
shopId String

the shopId to create packages for

Returns:

returns insert result

Type
String

(static) isPackageEnabled(name) → {Boolean}

Check if package is enabled

Source:
Example
Reaction.isPackageEnabled()
Parameters:
Name Type Description
name String

Package name

Returns:

True if the package is enabled

Type
Boolean

(static) isShopPrimary() → {Boolean}

Whether the current shop is the Primary Shop (vs a Merchant Shop)

Source:
Returns:

whether shop is flagged as primary

Type
Boolean

(static) loadPackages() → {String}

Insert Reaction packages into registry we check to see if the number of packages have changed against current data if there is a change, we'll either insert or upsert package registry into the Packages collection import is processed on hook in init()

Source:
Returns:

returns insert result

Type
String

(static) loadSettings(json) → {Boolean}

This basically allows you to "hardcode" all the settings. You can change them via admin etc for the session, but when the server restarts they'll be restored back to the supplied json

All settings are private unless added to settings.public

Meteor account services can be added in settings.services

Source:
Example
ReactionRegistry.loadSettings Assets.getText("settings/reaction.json")
Parameters:
Name Type Description
json Object

json object to insert

Returns:

boolean - returns true on insert

Type
Boolean

(static) processTemplateInfoForDatabase(templateInfo) → {Object|String|String|String|String|String}

Return templateData with name, title, type, subject, templateFor

Source:
Parameters:
Name Type Description
templateInfo Object

Object with templateInfo

Properties
Name Type Description
template String

template

parser String

React or Handlebars

Returns:
  • templateData

    Type
    Object
  • templateData.name

    Type
    String
  • templateData.title

    Type
    String
  • templateData.type

    Type
    String
  • templateData.subject

    Type
    String
  • templateData.templateFor

    Type
    String

(static) processTemplateInfoForMemoryCache(templateInfo) → {Boolean|null}

Sets parser to Handlebars for string-based templates and React for functions, objects

Source:
Parameters:
Name Type Description
templateInfo Object
Properties
Name Type Description
template String

Accepted values: string, function, object

Returns:

True on success or null

Type
Boolean | null

(static) registerTemplate() → {function}

Registers Templates into the Templates Collection

Source:
Returns:

Registers template

Type
function

(static) registerTemplate(templateInfo, shopId, insertImmediatelyopt) → {Object}

Source:
Parameters:
Name Type Attributes Default Description
templateInfo String

[description]

shopId String

[description]

insertImmediately Boolean <optional>
false

[description]

Returns:

Returns templateLiteral and templateReference

Type
Object

(static) registerTemplateForDatabase(templateInfo) → {Object}

Process template info for use in a database Namely, any literals like functions are stripped as they cannot be safely, and should not stored in the database

Source:
Parameters:
Name Type Description
templateInfo Object

Template info with parser info

Returns:

Return template data crafted for entry into a database

Type
Object

(static) registerTemplateForMemoryCache(templateInfo, shopId) → {Object}

Process template info and cache in memory. This allows us to have function and class references for the templates for React and other custom parsers

Source:
Parameters:
Name Type Description
templateInfo Object

Template info with parser info

shopId String

Shop ID

Returns:

Template from cache

Type
Object

(static) sendResetEmail(userId, optionalEmailopt) → {Job}

Send an email with a link that the user can use to reset their password.

Source:
Parameters:
Name Type Attributes Description
userId String

The id of the user to send email to.

optionalEmail String <optional>

Address to send the email to. This address must be in the user's emails list. Defaults to the first email in the list.

Returns:
  • returns a sendEmail Job instance
Type
Job

(static) sendUpdatedVerificationEmail(userId, emailopt) → {Job}

Send an email with a link the user can use to verify their updated email address.

Source:
Parameters:
Name Type Attributes Description
userId String

The id of the user to send email to.

email String <optional>

Optional. Address to send the email to. This address must be in the user's emails list. Defaults to the first unverified email in the list.

Returns:
  • returns a sendEmail Job instance
Type
Job

(static) sendVerificationEmail(userId, emailopt) → {Job}

Send an email with a link the user can use verify their email address.

Source:
Parameters:
Name Type Attributes Description
userId String

The id of the user to send email to.

email String <optional>

Optional. Address to send the email to. This address must be in the user's emails list. Defaults to the first unverified email in the list.

Returns:
  • returns a sendEmail Job instance
Type
Job

(static) setAppVersion() → {undefined}

Source:
Returns:

no return value

Type
undefined

(static) setDomain() → {String}

update the default shop url if ROOT_URL supplied is different from current

Source:
Returns:

returns insert result

Type
String

(static) setShopName(shop) → {undefined}

when new shop is created, set shop name if REACTION_SHOP_NAME env var exists

Source:
Example
Reaction.setShopName(shop)
 
Parameters:
Name Type Description
shop Object

Shops document with _id property

Returns:

undefined

Type
undefined

(static) setUserPreferences(packageName, preference, value, userId) → {Number}

save user preferences in the Accounts collection

Source:
Parameters:
Name Type Description
packageName String
preference String
value String
userId String
Returns:

setPreferenceResult

Type
Number