Interface CartFacade

    • 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,
                                       java.lang.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 {@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
      • 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,
                                             java.lang.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

        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 use CheckoutFacade.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 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​(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
      • 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 validation
        IllegalQuoteStateException - if the cart is associated with a quote for which the operation cannot be performed