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 Details

    • 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(String code, long quantity) throws CommerceCartModificationException
      Method for adding a product to cart.
      Parameters:
      code - code of product to add
      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(String code, long quantity, String storeId) throws CommerceCartModificationException
      Method for adding a product to cart.
      Parameters:
      code - code of product to add
      storeId - 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

      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 number
      quantity - 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 number
      storeId - 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(since="1808", forRemoval=true) List<CountryData> getDeliveryCountries()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 1808. Please use CheckoutFacade.getCountries(CountryType) instead.
      Get the supported delivery countries. The list is sorted alphabetically.
      Returns:
      list of supported delivery countries.
    • estimateExternalTaxes

      CartData estimateExternalTaxes(String deliveryZipCode, String countryIsoCode)
      Estimate taxes on the cart.
      Parameters:
      deliveryZipCode - delivery zip code used for calculating external taxes
      countryIsoCode - 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

      List<CartData> getCartsForCurrentUser()
      Returns all carts for current site and user.
      Returns:
      list of carts
    • getMostRecentCartGuidForUser

      default String getMostRecentCartGuidForUser(Collection<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 String 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 done
      toUserCartGuid - - User's cart to merge to
      Returns:
      CartRestorationData object holding information about the restoration
      Throws:
      CommerceCartMergingException
      CommerceCartRestorationException
    • 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 done
      toUserCartGuid - - User's cart to merge to
      Returns:
      CartRestorationData object holding information about the restoration
      Throws:
      CommerceCartRestorationException
      CommerceCartMergingException
    • updateCartEntry

      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:
      IllegalArgumentException - if any attributes fail validation
      IllegalQuoteStateException - 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