Interface CartFacade
- All Known Implementing Classes:
CommerceWebServicesCartFacade,CommerceWebServicesCartFacade,DefaultCartFacade,DefaultCartFacade,DefaultSaveCartFacade
public interface CartFacade
Cart facade interface. Service is responsible for getting all necessary information for cart, including delivery
details.
-
Method Summary
Modifier and TypeMethodDescriptionaddToCart(AddToCartParams addToCartParams) Method for adding a product to cart.Method for adding a product to cart.Method for adding a product to cart.estimateExternalTaxes(String deliveryZipCode, String countryIsoCode) Estimate taxes on the cart.Returns all carts for current site and user.Deprecated, for removal: This API element is subject to removal in a future version.since 1808.Method gets smaller version of cart, with data necessary for showing mini cart.default StringgetMostRecentCartGuidForUser(Collection<String> excludedCartsGuid) Returns most recent cart guid for current site and user excluding the list of carts guid passed.Method gets cart from session, if any exist.default StringReturns session cart guid if any.getSessionCartWithEntryOrdering(boolean recentlyAddedFirst) Method gets cart sorted by recently added entries from session, if param is set to truebooleanCheck if session cart has entries, avoiding full conversion of the cart to CartData.booleanCheck if session has a cart.removeEntryGroup(Integer groupNumber) Removes group with all subsequent entries.voidIf existing the current session cart is being detached from this session and removed.voidRemove the stale carts of the current user.restoreAnonymousCartAndMerge(String fromAnonumousCartGuid, String toUserCartGuid) Merges carts from anonymous to given user's cart, restores user's cart to the session, sets its user to current user.Restores the anonymous user's cart to the session and sets its user to current user.restoreCartAndMerge(String fromUserCartGuid, String toUserCartGuid) Merges user's carts, restores merged cart to the session, sets its user to current user.restoreSavedCart(String guid) Restores the user's saved cart to the session.updateCartEntry(long entryNumber, long quantity) Method for updating the number of products.updateCartEntry(long entryNumber, String storeId) Method for updating the number of products.updateCartEntry(OrderEntryData cartEntry) Updates the given cart entry.voidupdateCartMetadata(CommerceCartMetadata metadata) Updates cart metadata, such as: name, description, expiration time.Method for validating every entry in the cart
-
Method Details
-
getSessionCart
CartData getSessionCart()Method gets cart from session, if any exist.- Returns:
- the cart data
-
getSessionCartWithEntryOrdering
Method gets cart sorted by recently added entries from session, if param is set to true- Parameters:
recentlyAddedFirst- boolean value to determine whether to return sorted cart data- Returns:
- the cart data sorted by recently added entries
-
hasSessionCart
boolean hasSessionCart()Check if session has a cart.- Returns:
- true if the session has a cart
-
hasEntries
boolean hasEntries()Check if session cart has entries, avoiding full conversion of the cart to CartData. For Performance.- Returns:
- true if the cart has any entries.
-
getMiniCart
CartData getMiniCart()Method gets smaller version of cart, with data necessary for showing mini cart.- Returns:
- the mini card data
-
addToCart
Method for adding a product to cart.- Parameters:
code- code of product to addquantity- the quantity of the product- Returns:
- the cart modification data that includes a statusCode and the actual quantity added to the cart
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
addToCart
CartModificationData addToCart(String code, long quantity, String storeId) throws CommerceCartModificationException Method for adding a product to cart.- Parameters:
code- code of product to addstoreId- The identifier for the store. If null is used.quantity- the quantity of the product- Returns:
- the cart modification data that includes a statusCode and the actual quantity added to the cart
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
addToCart
CartModificationData addToCart(AddToCartParams addToCartParams) throws CommerceCartModificationException Method for adding a product to cart.- Parameters:
addToCartParams- addToCartParams- Returns:
- the cart modification data that includes a statusCode and the actual quantity added to the cart
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
validateCartData
Method for validating every entry in the cart- Returns:
- a list of cart modifications that includes a statusCode and the actual quantity that the entry was updated to
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
updateCartEntry
CartModificationData updateCartEntry(long entryNumber, long quantity) throws CommerceCartModificationException Method for updating the number of products.- Parameters:
entryNumber- the entry numberquantity- new value of quantity for product- Returns:
- the cart modification data that includes a statusCode and the actual quantity that the entry was updated to
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
updateCartEntry
CartModificationData updateCartEntry(long entryNumber, String storeId) throws CommerceCartModificationException Method for updating the number of products.- Parameters:
entryNumber- The entry numberstoreId- The identifier for the store. Can be null.- Returns:
- the cart modification data that includes a statusCode and the actual quantity that the entry was updated to
- Throws:
CommerceCartModificationException- if the cart cannot be modified
-
restoreSavedCart
Restores the user's saved cart to the session. For non-anonymous users, the cart restored will be for the current user and site.- Parameters:
guid- the cart guid to restore for Anonymous user.- Returns:
- the cart restoration data that includes details of any items that could not be restored in part or in full.
- Throws:
CommerceCartRestorationException
-
getDeliveryCountries
Deprecated, for removal: This API element is subject to removal in a future version.since 1808. Please useCheckoutFacade.getCountries(CountryType)instead.Get the supported delivery countries. The list is sorted alphabetically.- Returns:
- list of supported delivery countries.
-
estimateExternalTaxes
Estimate taxes on the cart.- Parameters:
deliveryZipCode- delivery zip code used for calculating external taxescountryIsoCode- delivery country used for calculating taxes- Returns:
- cart data that represents the current cart with taxes estimations added
-
removeStaleCarts
void removeStaleCarts()Remove the stale carts of the current user. -
restoreAnonymousCartAndTakeOwnership
CartRestorationData restoreAnonymousCartAndTakeOwnership(String guid) throws CommerceCartRestorationException Restores the anonymous user's cart to the session and sets its user to current user.- Parameters:
guid- GUID used to find anonymous user's cart- Returns:
- the cart restoration data that includes details of any items that could not be restored in part or in full.
- Throws:
CommerceCartRestorationException
-
removeSessionCart
void removeSessionCart()If existing the current session cart is being detached from this session and removed. Afterwards it's no longer available. -
getCartsForCurrentUser
Returns all carts for current site and user.- Returns:
- list of carts
-
getMostRecentCartGuidForUser
Returns most recent cart guid for current site and user excluding the list of carts guid passed.- Parameters:
excludedCartsGuid- the excluded carts guid- Returns:
- the cart guid
-
getSessionCartGuid
Returns session cart guid if any.- Returns:
- the session cart guid
-
restoreAnonymousCartAndMerge
CartRestorationData restoreAnonymousCartAndMerge(String fromAnonumousCartGuid, String toUserCartGuid) throws CommerceCartMergingException, CommerceCartRestorationException Merges carts from anonymous to given user's cart, restores user's cart to the session, sets its user to current user.- Parameters:
fromAnonumousCartGuid- - Anonymous user's cart from merging is donetoUserCartGuid- - User's cart to merge to- Returns:
CartRestorationDataobject holding information about the restoration- Throws:
CommerceCartMergingExceptionCommerceCartRestorationException
-
restoreCartAndMerge
CartRestorationData restoreCartAndMerge(String fromUserCartGuid, String toUserCartGuid) throws CommerceCartRestorationException, CommerceCartMergingException Merges user's carts, restores merged cart to the session, sets its user to current user.- Parameters:
fromUserCartGuid- - User's cart from merging is donetoUserCartGuid- - User's cart to merge to- Returns:
CartRestorationDataobject holding information about the restoration- Throws:
CommerceCartRestorationExceptionCommerceCartMergingException
-
updateCartEntry
CartModificationData updateCartEntry(OrderEntryData cartEntry) throws CommerceCartModificationException Updates the given cart entry.- Parameters:
cartEntry- the order entry data object identifying the order entry to update and holding the updated attributes.- Returns:
- the cart modification data that includes a statusCode and the actual quantity that the entry was updated
- Throws:
CommerceCartModificationException
-
updateCartMetadata
Updates cart metadata, such as: name, description, expiration time.- Parameters:
metadata- a bean holding parameters a client may want to pass to the method, attributes can be added to the bean via beans.xml in your extensions- Throws:
IllegalArgumentException- if any attributes fail validationIllegalQuoteStateException- if the cart is associated with a quote for which the operation cannot be performed
-
removeEntryGroup
CartModificationData removeEntryGroup(@Nonnull Integer groupNumber) throws CommerceCartModificationException Removes group with all subsequent entries.- Parameters:
groupNumber- group number- Returns:
- cart modification data with status code: "invalidGroupNumber" - group not found, "notPermitted" - group can not be removed, null - OK
- Throws:
CommerceCartModificationException
-