Interface CartFacade
-
- All Known Implementing Classes:
CommerceWebServicesCartFacade,DefaultCartFacade,DefaultCartFacade,DefaultSapCartFacade,DefaultSaveCartFacade
public interface CartFacadeCart facade interface. Service is responsible for getting all necessary information for cart, including delivery details.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description CartModificationDataaddToCart(AddToCartParams addToCartParams)Method for adding a product to cart.CartModificationDataaddToCart(java.lang.String code, long quantity)Method for adding a product to cart.CartModificationDataaddToCart(java.lang.String code, long quantity, java.lang.String storeId)Method for adding a product to cart.CartDataestimateExternalTaxes(java.lang.String deliveryZipCode, java.lang.String countryIsoCode)Estimate taxes on the cart.java.util.List<CartData>getCartsForCurrentUser()Returns all carts for current site and user.java.util.List<CountryData>getDeliveryCountries()Deprecated.since 1808.CartDatagetMiniCart()Method gets smaller version of cart, with data necessary for showing mini cart.default java.lang.StringgetMostRecentCartGuidForUser(java.util.Collection<java.lang.String> excludedCartsGuid)Returns most recent cart guid for current site and user excluding the list of carts guid passed.CartDatagetSessionCart()Method gets cart from session, if any exist.default java.lang.StringgetSessionCartGuid()Returns session cart guid if any.CartDatagetSessionCartWithEntryOrdering(boolean recentlyAddedFirst)Method gets cart sorted by recently added entries from session, if param is set to truebooleanhasEntries()Check if session cart has entries, avoiding full conversion of the cart to CartData.booleanhasSessionCart()Check if session has a cart.CartModificationDataremoveEntryGroup(java.lang.Integer groupNumber)Removes group with all subsequent entries.voidremoveSessionCart()If existing the current session cart is being detached from this session and removed.voidremoveStaleCarts()Remove the stale carts of the current user.CartRestorationDatarestoreAnonymousCartAndMerge(java.lang.String fromAnonumousCartGuid, java.lang.String toUserCartGuid)Merges carts from anonymous to given user's cart, restores user's cart to the session, sets its user to current user.CartRestorationDatarestoreAnonymousCartAndTakeOwnership(java.lang.String guid)Restores the anonymous user's cart to the session and sets its user to current user.CartRestorationDatarestoreCartAndMerge(java.lang.String fromUserCartGuid, java.lang.String toUserCartGuid)Merges user's carts, restores merged cart to the session, sets its user to current user.CartRestorationDatarestoreSavedCart(java.lang.String guid)Restores the user's saved cart to the session.CartModificationDataupdateCartEntry(long entryNumber, long quantity)Method for updating the number of products.CartModificationDataupdateCartEntry(long entryNumber, java.lang.String storeId)Method for updating the number of products.CartModificationDataupdateCartEntry(OrderEntryData cartEntry)Updates the given cart entry.voidupdateCartMetadata(CommerceCartMetadata metadata)Updates cart metadata, such as: name, description, expiration time.java.util.List<CartModificationData>validateCartData()Method for validating every entry in the cart
-
-
-
Method Detail
-
getSessionCart
CartData getSessionCart()
Method gets cart from session, if any exist.- Returns:
- the cart data
-
getSessionCartWithEntryOrdering
CartData getSessionCartWithEntryOrdering(boolean recentlyAddedFirst)
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
CartModificationData addToCart(java.lang.String code, long quantity) throws CommerceCartModificationException
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(java.lang.String code, long quantity, java.lang.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 {@see CartFacade#addToCart(String, long)} 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
java.util.List<CartModificationData> validateCartData() throws CommerceCartModificationException
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, java.lang.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
CartRestorationData restoreSavedCart(java.lang.String guid) throws CommerceCartRestorationException
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(since="1808") java.util.List<CountryData> getDeliveryCountries()
Deprecated.since 1808. Please useCheckoutFacade.getCountries(CountryType)instead.Get the supported delivery countries. The list is sorted alphabetically.- Returns:
- list of supported delivery countries.
-
estimateExternalTaxes
CartData estimateExternalTaxes(java.lang.String deliveryZipCode, java.lang.String countryIsoCode)
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(java.lang.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
java.util.List<CartData> getCartsForCurrentUser()
Returns all carts for current site and user.- Returns:
- list of carts
-
getMostRecentCartGuidForUser
default java.lang.String getMostRecentCartGuidForUser(java.util.Collection<java.lang.String> excludedCartsGuid)
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
default java.lang.String getSessionCartGuid()
Returns session cart guid if any.- Returns:
- the session cart guid
-
restoreAnonymousCartAndMerge
CartRestorationData restoreAnonymousCartAndMerge(java.lang.String fromAnonumousCartGuid, java.lang.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(java.lang.String fromUserCartGuid, java.lang.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
void updateCartMetadata(CommerceCartMetadata metadata)
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:
java.lang.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 java.lang.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
-
-