Server core methods
Methods
(static) addRolesToGroups(context, options) → {undefined}
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"]
Parameters:
Name | Type | Description |
---|---|---|
context |
Object | App context |
options |
Object | See above for details |
Returns:
- Type
- undefined
(static) canInviteToGroup(options) → {Boolean}
checks if the user making the request is allowed to make invitation to that group
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Properties
|
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.
Returns:
- Type
- undefined
(static) createGroups(context, shopId) → {undefined}
creates groups for a shop
Parameters:
Name | Type | Description |
---|---|---|
context |
Object | App context |
shopId |
String | ID of shop to create the group for |
Returns:
- Type
- undefined
(static) getCartShopId() → {StringId}
Get the correct shop ID to use for Cart collection
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
Returns:
Shop domain
- Type
- String
(static) getMarketplaceSettings() → {Object}
finds the enabled reaction-marketplace
package for
the primary shop and returns the settings
Returns:
The marketplace settings from the primary shop or undefined
- Type
- Object
(static) getPackageSettings(name) → {Object|null}
Get package settings
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Package name |
Returns:
Package setting object or null
- Type
- Object | null
(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
Returns:
Shop
- Type
- Object
(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
Returns:
ID
- Type
- String
(static) getPrimaryShopName() → {String}
Get primary shop name or empty string
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
Returns:
Get settings object or empty object
- Type
- Object
(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}
Returns:
Shop ID
- Type
- String
(static) getShopCurrencies() → {Object}
Get all currencies available to a shop
Returns:
Shop currency or "USD"
- Type
- Object
(static) getShopCurrency() → {String}
Get shop currency
Returns:
Shop currency or "USD"
- Type
- String
(static) getShopEmail() → {String}
Get shop email
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
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
Returns:
Shop name or empty string ""
- Type
- String
(static) getShopSettings(nameopt) → {Object}
Get shop settings object
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
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
|
Returns:
Array of tag IDs
- Type
- Array
(static) getUserShopId(userId) → {String}
Get a user's shop ID, as stored in preferences
Parameters:
Name | Type | Description |
---|---|---|
userId |
String | (probably logged in userId) |
Returns:
active shop ID
- Type
- String
(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}
Returns:
Boolean - true if has permission
- Type
- Boolean
(static) hasDashboardAccess() → {Boolean}
Returns:
Boolean - true if has permission
- Type
- Boolean
(static) hasOwnerAccess() → {Boolean}
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.
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) 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)
Returns:
whether shop is flagged as primary
- Type
- Boolean
(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
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) sendResetEmail(context, account, email) → {Job}
Send an email with a link that the user can use to reset their password.
Parameters:
Name | Type | Description |
---|---|---|
context |
Object | GraphQL execution context |
account |
Object | account object that is related to email address |
email |
String | email of account to reset |
Returns:
- returns a sendEmail Job instance
- Type
- Job
(static) sendResetEmail(userId, optionalEmailopt, language) → {Job}
Send an email with a link that the user can use to reset their password.
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 |
language |
String | user prefered language i18n |
Returns:
- returns a sendEmail Job instance
- Type
- Job
(static) setDomain() → {String}
update the default shop url if ROOT_URL supplied is different from current
Returns:
returns insert result
- Type
- String