ccrz.ccApiCart.fetch
Executes a SOQL query of cart records, and returns a list of carts that match your
query.
Compatibility
This reference applies to:
Release | Managed Package Version | API Version |
---|---|---|
B2B Commerce for Visualforce Winter ’21 | 4.13 | 12 |
B2B Commerce for Visualforce Spring ’20 | 4.12 | 11 |
B2B Commerce for Visualforce Summer ’19 | 4.11 | 10 |
B2B Commerce for Visualforce Spring ’19 | 4.10 | 9 |
B2B Commerce for Visualforce Summer ’18 | 4.9 | 8 |
Signature
global static Map<String, Object> fetch(Map<String, Object>)
Service Layer Classes
- Data Service Provider
- ccrz.ccServiceCart
Inputs (Required)
Map<String, Object> that must include the following required keys:
- ccrz.ccApi.API_VERSION
- The version of the B2B Commerce for Visualforce API to reference for the method call. We recommend that you use the ccrz.ccApi.CURRENT_VERSION constant whenever possible, and only reference a specific version for compatibility if necessary.
Inputs (Optional)
The input map can also include the following keys:
- ccrz.ccApi.API_SIZING
- Map<String, Object> that specifies the scope of data that this method returns, including which fields the method returns for each record that matches the query.
- ccrz.ccApiCart.ACTIVECART
- Boolean
Value Usage true Return the active cart for a specific owner. Use this key with when you also specify ccrz.ccApiCart.BYOWNER. false (default) Return all carts that match the other query criteria. - ccrz.ccApiCart.BYOWNER
- String that specifies the ID of a specific user. Return only cart records where the Owner field matches this user ID.
- ccrz.ccApiCart.BYUSER
- String that specifies the ID of a specific user. Return only cart records where the User field matches this user ID.
- ccrz.ccApiCart.BYSTOREFRONT
- String that specifies the name of a storefront for filtering the query.
- ccrz.ccApiCart.CART_ENCID
- String that specifies the encrypted ID of the cart to query.
- ccrz.ccApiCart.CART_ENCIDLIST
- Set<String> of encrypted cart IDs to query.
- ccrz.ccApiCart.CART_IDLIST
- Set<String> of cart IDs to query.
- ccrz.ccApiCart.CARTNAME
- String that specifies a cart name to query. This value corresponds to the Cart Auto Number (Name) field on the cart record.
- ccrz.ccApiCart.CARTSTATUS
- String that specifies a cart status for filtering records in the return data. This value corresponds to the ccrz__CartStatus__c field on the cart record.
- ccrz.ccApiCart.CARTTYPE
- Deprecated. The managed package no longer references this key.
- ccrz.ccService.SEARCHSTRING
- String that specifies filter criteria to pass to the ccrz.ccApiCart.fetchCartItems method.
Outputs
Map<String, Object> that can include the following keys:
- ccrz.ccApi.API_VERSION
- Integer that indicates which API version was used for the query.
- ccrz.ccApi.SUCCESS
- Boolean
Value Usage true The call completed. false The call encountered errors. - ccrz.ccApiAddress.ADDRESSLIST
- List<Map<String, Object>>, where each Map<String, Object> represents a ccrz__E_ContactAddr__c associated with the cart's shipping or billing addresses. For more information about fetching address data, see ccrz.ccApiAddress.fetch.
- ccrz.ccApiCart.CART_OBJLIST
- List<Map<String, Object>>, where each Map<String, Object> represents a ccrz__E_Cart__c record that matches the query. By default, this list sorts by each cart's last modified date in descending order.
- ccrz.ccApiProduct.PRODUCTLIST
- List<Map<String, Object>>, where each Map<String, Object> represents a ccrz__E_Product__c associated with the cart's items. For more information about fetching product data, see ccrz.ccApiProduct.fetch.
Examples
Query a pair of cart IDs, and capture the first cart's status in a variable.
Set<String> cartIdList = new Set<String>{'CART_ID_1', 'CART_ID_2'};
Map<String, Object> cartFetchQuery = new Map<String, Object>{
ccrz.ccApiCart.CART_IDLIST => cartIdList,
ccrz.ccApi.API_VERSION => ccrz.ccApi.CURRENT_VERSION
};
try {
Map<String, Object> cartFetchData = ccrz.ccApiCart.fetch(cartFetchQuery);
if (cartFetchData.get(ccrz.ccApiCart.CART_OBJLIST) != null) {
List<Map<String, Object>> outputCartList = (List<Map<String, Object>>) cartFetchData.get(ccrz.ccApiCart.CART_OBJLIST);
String firstCartStatus = (String) outputCartList[0].get('cartStatus');
}
} catch (Exception e) {
// Error handling...
}
Query all carts with a status of Abandoned.
Map<String, Object> cartFetchQuery = new Map<String, Object>{
ccrz.ccApiCart.CARTSTATUS => 'Abandoned',
ccrz.ccApi.API_VERSION => ccrz.ccApi.CURRENT_VERSION
};
try {
Map<String, Object> cartFetchData = ccrz.ccApiCart.fetch(cartFetchQuery);
if (cartFetchData.get(ccrz.ccApiCart.CART_OBJLIST) != null) {
List<Map<String, Object>> outputCartList = (List<Map<String, Object>>) cartFetchData.get(ccrz.ccApiCart.CART_OBJLIST);
}
} catch (Exception e) {
// Error handling...
}