Constructor
new MerlinsConnector()
Methods
(static) fromConfig(config) → {module:@mobify/commerce-integrations/dist/types.MerlinsConnector}
Given a configuration in the form of a plain object, this method returns a new MerlinsConnector instance.
Parameters:
| Name | Type | Description |
|---|---|---|
config |
Object |
- Source:
Returns:
The new MerlinsConnector instance.
- Type
- module:@mobify/commerce-integrations/dist/types.MerlinsConnector
addCartItem(cart, cartItem, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Adds a cart item to cart.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart to add the cart item to. |
cartItem |
module:@mobify/commerce-integrations/dist/types.CartItem | The cart item to add. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
addCouponEntry(cart, couponEntry, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Add a coupon to the cart by it's code.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The customer's cart. |
couponEntry |
Object | The coupon. |
opts |
Object | Options object. |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
createCart(oldCcart, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Creates a new cart with an optional cart object.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
oldCcart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart you'd like to migrate to the new cart |
|
opts |
Object |
<optional> |
object |
- Implements:
- Source:
Throws:
Could not create cart.
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
createOrder(cart, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Order>}
Create a new order using a given cart.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The customer's cart. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Order>
deleteCart(cartId, optsopt)
Deletes the given cart
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cartId |
String | The id of the cart you want to delete. |
|
opts |
Object |
<optional> |
object |
- Implements:
- Source:
Throws:
Could not delete cart.
getCart(cartId, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Retrieve cart by id.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cartId |
String | The id of the cart you want to retrieve |
|
opts |
Object |
<optional> |
object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
getCategories(ids, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.CategoryList>}
Returns multiple product Categories by their ids.
On supported backends this method will retrieve Categories in a single network call. Others may make a call per id to emulate the same behaviour.
Invalid ids are ignored and results are not guaranteed to be returned in the order requested.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ids |
Array.<string> | ||
opts |
Object |
<optional> |
object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.CategoryList>
getCategory(id, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.Category>}
Get a product Category by id.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
String | ||
opts |
Object |
<optional> |
object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Category>
getCustomer(id, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.Customer>}
Return a customer's details by id.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
String | Customer Id |
|
opts |
Object |
<optional> |
Options object |
- Implements:
- Source:
Throws:
-
Throw generic error if server has error.
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Customer>
getOrder(id, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.Order>}
Get a single order by id.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
String | The order id. |
|
opts |
Object |
<optional> |
Options object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Order>
getOrders(ids, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.OrderList>}
Get multiple orders by their ids.
On supported backends this method will retrieve orders in a single network call. Others may make a call per id to emulate the same behaviour.
Invalid ids are ignored and results are not guaranteed to be returned in the order requested.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ids |
Array.<String> | The order ids. |
|
opts |
Object |
<optional> |
Options object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.OrderList>
getPaymentMethods(cart, opts) → {Promise.<Array.<module:@mobify/commerce-integrations/dist/types.PaymentMethod>>}
Get the available payment methods for the cart.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The customer's cart. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<Array.<module:@mobify/commerce-integrations/dist/types.PaymentMethod>>
getProduct(id, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.Product>}
Get a single product by id.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
String | The product id. |
|
opts |
Object |
<optional> |
Options object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Product>
getProducts(ids, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.ProductList>}
Get multiple products by their ids.
On supported backends this method will retrieve products in a single network call. Others may make a call per id to emulate the same behaviour.
Invalid ids are ignored and results are not guaranteed to be returned in the order requested.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ids |
Array.<String> | The product ids. |
|
opts |
Object |
<optional> |
Options object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.ProductList>
getSearchUrl(productSearchRequest) → {String}
Takes commerce-integrations ProductSearchRequest type and returns the URL representation used to query the website.
Parameters:
| Name | Type | Description |
|---|---|---|
productSearchRequest |
module:@mobify/commerce-integrations/dist/types.ProductSearchRequest |
- Source:
Returns:
- Type
- String
getShippingMethods(cart, opts) → {Promise.<Array.<module:@mobify/commerce-integrations/dist/types.ShippingMethod>>}
Get all the available shipping methods given the cart details.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart to determinen avaialble shipping methods for. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<Array.<module:@mobify/commerce-integrations/dist/types.ShippingMethod>>
getStore(id, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.Store>}
Get a Store (ie. a physical retail-outlet) by id. Includes addresses, opening hours, etc.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
String | The id of the store |
|
opts |
Object |
<optional> |
Options object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Store>
login(username, password) → {Promise.<module:@mobify/commerce-integrations/dist/types.Customer>}
Log a customer in and return their details.
On backends which support "guest login", credentials can be omitted to give you a guest session.
Parameters:
| Name | Type | Description |
|---|---|---|
username |
String | |
password |
String |
- Implements:
- Source:
Throws:
-
-
Will throw an error if the username or password aren't provided for type registered.
-
-
-
Will throw an error if the customer credentials are incorrect.
-
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Customer>
logout() → {Promise.<undefined>}
Log a customer out.
- Implements:
- Source:
Throws:
-
Will throw an error if there was a server-side error.
Returns:
- Type
- Promise.<undefined>
parseCartItem()
Parse a cart item cart item will not have price until a payment is set.
- Source:
parseCartTotals()
Parse the cart money totals totals not calculated until shipping address/method is set.
- Source:
parseCategory(htmlDoc) → {Promise.<module:@mobify/commerce-integrations/dist/types.Category>}
Takes a html element that represents a category and parses it into a commerce-integrations Category type.
Parameters:
| Name | Type | Description |
|---|---|---|
htmlDoc |
Object | a Element object |
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Category>
parseCouponEntry()
Parse a coupon item
- Source:
parseFilter(optionEl) → {module:@mobify/commerce-integrations/dist/types.Filter}
Takes a dom element representing a merlins filter and parses out an commerce-integrations Filter type.
Parameters:
| Name | Type | Description |
|---|---|---|
optionEl |
Object | a Element object |
- Source:
Returns:
parseFilters(filterOptionsEl, currentUrl) → {Array.<module:@mobify/commerce-integrations/dist/types.Filter>}
Takes a dom element and parses out an array of commerce-integrations Filter type.
Parameters:
| Name | Type | Description |
|---|---|---|
filterOptionsEl |
Object | a Element object |
currentUrl |
String | The current page url used to help determine filter values. |
- Source:
Returns:
parseOrder()
- Source:
parseOrderAddress()
Parse an order address
- Source:
parsePaymentMethod()
Parse a payment method
- Source:
parseProduct(data) → {Promise.<module:@mobify/commerce-integrations/dist/types.Store>}
Takes a OCAPI Product object and parses it into a commerce-integrations Product type.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | a OCAPI Product document |
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Store>
parseProductSearchResult(productEl) → {module:@mobify/commerce-integrations/dist/types.ProductSearchResult}
Takes a dom element representing a merlins search result product tile and parses out an commerce-integrations ProductSearchResult type.
Parameters:
| Name | Type | Description |
|---|---|---|
productEl |
Object | a Element object |
- Source:
Returns:
parseSearchProducts()
- Source:
parseSelectedFilter(selectedEl, currentUrl) → {module:@mobify/commerce-integrations/dist/types.Filter}
Takes a dom element representing a merlins selected filter and parses out a commerce-integrations Filter type.
Parameters:
| Name | Type | Description |
|---|---|---|
selectedEl |
Object | a Element object |
currentUrl |
String | The current page url used to help determine filter values. |
- Source:
Returns:
parseSelectedFilters(selectedFiltersEl, currentUrl) → {Array.<module:@mobify/commerce-integrations/dist/types.Filter>}
Takes a dom element and parses out an array of commerce-integrations Filter type representing those filters that are selected.
Parameters:
| Name | Type | Description |
|---|---|---|
selectedFiltersEl |
Object | a Element object |
currentUrl |
String | The current page url used to help determine filter values. |
- Source:
Returns:
parseShippingMethod()
Parse a shipping method
- Source:
parseSortingOptions(sortEl) → {Array.<module:@mobify/commerce-integrations/dist/types.SortOption>}
Takes a dom element representing a merlins sorting select and parses out an array od commerce-integrations SortOption type.
Parameters:
| Name | Type | Description |
|---|---|---|
sortEl |
Object | a Element object |
- Source:
Returns:
refreshSession() → {Promise.<module:@mobify/commerce-integrations/dist/types.Customer>}
Refresh a session token, on backends that support refresh.
- Implements:
- Source:
Throws:
-
Will throw an error if authorization credentials are incorrect
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Customer>
registerCustomer(data) → {Promise.<module:@mobify/commerce-integrations/dist/types.Customer>}
Register a new customer account and login.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
module:@mobify/commerce-integrations/dist/types.CustomerRegistration |
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Customer>
removeCartItem(cart, cartItemId, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Remove a cart item from the cart.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart to remove the cart item from. |
cartItemId |
String | The id of the cart item to remove. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
removeCouponEntry(cart, couponEntryId, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Removes a coupon from the cart by its coupon entry id.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The customer's cart. |
couponEntryId |
Object | The coupon entry id. |
opts |
Object | Options object. |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
searchProducts(productSearchRequest, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.ProductSearch>}
Search for products, given a productSearchRequest object.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
productSearchRequest |
module:@mobify/commerce-integrations/dist/types.ProductSearchRequest | Search query |
|
opts |
Object |
<optional> |
Options object |
- Implements:
- Source:
Returns:
searchStores(storeSearchRequest, optsopt) → {Promise.<module:@mobify/commerce-integrations/dist/types.StoreSearchResult>}
Searches for Stores (ie. physical retail-outlets).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
storeSearchRequest |
module:@mobify/commerce-integrations/dist/types.StoreSearchRequest | ||
opts |
Object |
<optional> |
Options object |
- Implements:
- Source:
Returns:
setBillingAddress(cart, billingAddress, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Set the billing address on the cart.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart to update the billing address for. |
billingAddress |
module:@mobify/commerce-integrations/dist/types.OrderAddress | The new or modified address. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
setCustomerInformation()
This updates the given cart object with the given customerInformation object and returns it. It will not persist in the backend until a payment is added.
- Implements:
- Source:
setPayment(cart, payment, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Add a supported payment type to the cart
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart to remove the payment from. |
payment |
module:@mobify/commerce-integrations/dist/types.Payment | The payment to add. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
setShippingAddress(cart, shippingAddress, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Set the shipping address on the cart.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart to update the shipping address for. |
shippingAddress |
module:@mobify/commerce-integrations/dist/types.OrderAddress | The new or modified address. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
setShippingMethod(cart, shippingMethod, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Set the shipping method for the cart.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart to set the shipping method for. |
shippingMethod |
module:@mobify/commerce-integrations/dist/types.ShippingMethod | The shipping method to set. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>
updateCartItem(cart, cartItem, opts) → {Promise.<module:@mobify/commerce-integrations/dist/types.Cart>}
Update an existing cart item in the cart.
Parameters:
| Name | Type | Description |
|---|---|---|
cart |
module:@mobify/commerce-integrations/dist/types.Cart | The cart to containing the cart item to update. |
cartItem |
module:@mobify/commerce-integrations/dist/types.CartItem | The cart item to update. |
opts |
Object |
- Implements:
- Source:
Returns:
- Type
- Promise.<module:@mobify/commerce-integrations/dist/types.Cart>