Class ShoppingCartHelper


  • public class ShoppingCartHelper
    extends java.lang.Object
    A facade over the ShoppingCart providing catalog and product services to simplify the interaction with the cart directly.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String module  
      static java.lang.String resource  
      static java.lang.String resource_error  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​java.lang.Object> addCategoryDefaults​(java.lang.String catalogId, java.lang.String categoryId, java.lang.String itemGroupNumber)
      Adds all products in a category according to default quantity on ProductCategoryMember for each; if no default for a certain product in the category, or if quantity is 0, do not add
      java.util.Map<java.lang.String,​java.lang.Object> addOrderTerm​(java.lang.String termTypeId, java.math.BigDecimal termValue, java.lang.Long termDays)  
      java.util.Map<java.lang.String,​java.lang.Object> addOrderTerm​(java.lang.String termTypeId, java.math.BigDecimal termValue, java.lang.Long termDays, java.lang.String textValue)  
      java.util.Map<java.lang.String,​java.lang.Object> addToCart​(java.lang.String catalogId, java.lang.String shoppingListId, java.lang.String shoppingListItemSeqId, java.lang.String productId, java.lang.String productCategoryId, java.lang.String itemType, java.lang.String itemDescription, java.math.BigDecimal price, java.math.BigDecimal amount, java.math.BigDecimal quantity, java.sql.Timestamp reservStart, java.math.BigDecimal reservLength, java.math.BigDecimal reservPersons, java.lang.String accommodationMapId, java.lang.String accommodationSpotId, java.sql.Timestamp shipBeforeDate, java.sql.Timestamp shipAfterDate, java.sql.Timestamp reserveAfterDate, ProductConfigWrapper configWrapper, java.lang.String itemGroupNumber, java.util.Map<java.lang.String,​? extends java.lang.Object> context, java.lang.String parentProductId)
      Event to add an item to the shopping cart with accommodation.
      java.util.Map<java.lang.String,​java.lang.Object> addToCart​(java.lang.String catalogId, java.lang.String shoppingListId, java.lang.String shoppingListItemSeqId, java.lang.String productId, java.lang.String productCategoryId, java.lang.String itemType, java.lang.String itemDescription, java.math.BigDecimal price, java.math.BigDecimal amount, java.math.BigDecimal quantity, java.sql.Timestamp reservStart, java.math.BigDecimal reservLength, java.math.BigDecimal reservPersons, java.lang.String accommodationMapId, java.lang.String accommodationSpotId, java.sql.Timestamp shipBeforeDate, java.sql.Timestamp shipAfterDate, ProductConfigWrapper configWrapper, java.lang.String itemGroupNumber, java.util.Map<java.lang.String,​? extends java.lang.Object> context, java.lang.String parentProductId)
      Overriden for reserveAfterDate.
      java.util.Map<java.lang.String,​java.lang.Object> addToCart​(java.lang.String catalogId, java.lang.String shoppingListId, java.lang.String shoppingListItemSeqId, java.lang.String productId, java.lang.String productCategoryId, java.lang.String itemType, java.lang.String itemDescription, java.math.BigDecimal price, java.math.BigDecimal amount, java.math.BigDecimal quantity, java.sql.Timestamp reservStart, java.math.BigDecimal reservLength, java.math.BigDecimal reservPersons, java.sql.Timestamp shipBeforeDate, java.sql.Timestamp shipAfterDate, ProductConfigWrapper configWrapper, java.lang.String itemGroupNumber, java.util.Map<java.lang.String,​? extends java.lang.Object> context, java.lang.String parentProductId)
      Event to add an item to the shopping cart.
      java.util.Map<java.lang.String,​java.lang.Object> addToCartBulk​(java.lang.String catalogId, java.lang.String categoryId, java.util.Map<java.lang.String,​? extends java.lang.Object> context)
      Adds all products in a category according to quantity request parameter for each; if no parameter for a certain product in the category, or if quantity is 0, do not add.
      java.util.Map<java.lang.String,​java.lang.Object> addToCartBulkRequirements​(java.lang.String catalogId, java.util.Map<java.lang.String,​? extends java.lang.Object> context)
      Adds a set of requirements to the cart.
      java.util.Map<java.lang.String,​java.lang.Object> addToCartFromOrder​(java.lang.String catalogId, java.lang.String orderId, java.lang.String[] itemIds, boolean addAll, java.lang.String itemGroupNumber)  
      boolean clearCart()
      Empty the shopping cart.
      java.util.Map<java.lang.String,​java.lang.Object> deleteFromCart​(java.util.Map<java.lang.String,​? extends java.lang.Object> context)
      Delete an item from the shopping cart.
      ShoppingCart getCartObject()
      Returns the shopping cart this helper is wrapping.
      GenericValue getFeatureAppl​(java.lang.String productId, java.lang.String optionField, java.lang.String featureId)  
      java.lang.String getRemoveFeatureTypeId​(java.lang.String optionField)  
      java.util.Map<java.lang.String,​java.lang.Object> modifyCart​(Security security, GenericValue userLogin, java.util.Map<java.lang.String,​? extends java.lang.Object> context, boolean removeSelected, java.lang.String[] selectedItems, java.util.Locale locale)
      Update the items in the shopping cart.
      java.util.Map<java.lang.String,​java.lang.Object> removeOrderTerm​(int index)  
      java.util.Map<java.lang.String,​java.lang.Object> selectAgreement​(java.lang.String agreementId)
      Select an agreement
      java.util.Map<java.lang.String,​java.lang.Object> setCurrency​(java.lang.String currencyUomId)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • module

        public static final java.lang.String module
    • Constructor Detail

      • ShoppingCartHelper

        public ShoppingCartHelper​(Delegator delegator,
                                  LocalDispatcher dispatcher,
                                  ShoppingCart cart)
        Changes will be made to the cart directly, as opposed to a copy of the cart provided.
        Parameters:
        cart - The cart to manipulate
    • Method Detail

      • addToCart

        public java.util.Map<java.lang.String,​java.lang.Object> addToCart​(java.lang.String catalogId,
                                                                                java.lang.String shoppingListId,
                                                                                java.lang.String shoppingListItemSeqId,
                                                                                java.lang.String productId,
                                                                                java.lang.String productCategoryId,
                                                                                java.lang.String itemType,
                                                                                java.lang.String itemDescription,
                                                                                java.math.BigDecimal price,
                                                                                java.math.BigDecimal amount,
                                                                                java.math.BigDecimal quantity,
                                                                                java.sql.Timestamp reservStart,
                                                                                java.math.BigDecimal reservLength,
                                                                                java.math.BigDecimal reservPersons,
                                                                                java.sql.Timestamp shipBeforeDate,
                                                                                java.sql.Timestamp shipAfterDate,
                                                                                ProductConfigWrapper configWrapper,
                                                                                java.lang.String itemGroupNumber,
                                                                                java.util.Map<java.lang.String,​? extends java.lang.Object> context,
                                                                                java.lang.String parentProductId)
        Event to add an item to the shopping cart.
      • addToCart

        public java.util.Map<java.lang.String,​java.lang.Object> addToCart​(java.lang.String catalogId,
                                                                                java.lang.String shoppingListId,
                                                                                java.lang.String shoppingListItemSeqId,
                                                                                java.lang.String productId,
                                                                                java.lang.String productCategoryId,
                                                                                java.lang.String itemType,
                                                                                java.lang.String itemDescription,
                                                                                java.math.BigDecimal price,
                                                                                java.math.BigDecimal amount,
                                                                                java.math.BigDecimal quantity,
                                                                                java.sql.Timestamp reservStart,
                                                                                java.math.BigDecimal reservLength,
                                                                                java.math.BigDecimal reservPersons,
                                                                                java.lang.String accommodationMapId,
                                                                                java.lang.String accommodationSpotId,
                                                                                java.sql.Timestamp shipBeforeDate,
                                                                                java.sql.Timestamp shipAfterDate,
                                                                                ProductConfigWrapper configWrapper,
                                                                                java.lang.String itemGroupNumber,
                                                                                java.util.Map<java.lang.String,​? extends java.lang.Object> context,
                                                                                java.lang.String parentProductId)
        Overriden for reserveAfterDate.
      • addToCart

        public java.util.Map<java.lang.String,​java.lang.Object> addToCart​(java.lang.String catalogId,
                                                                                java.lang.String shoppingListId,
                                                                                java.lang.String shoppingListItemSeqId,
                                                                                java.lang.String productId,
                                                                                java.lang.String productCategoryId,
                                                                                java.lang.String itemType,
                                                                                java.lang.String itemDescription,
                                                                                java.math.BigDecimal price,
                                                                                java.math.BigDecimal amount,
                                                                                java.math.BigDecimal quantity,
                                                                                java.sql.Timestamp reservStart,
                                                                                java.math.BigDecimal reservLength,
                                                                                java.math.BigDecimal reservPersons,
                                                                                java.lang.String accommodationMapId,
                                                                                java.lang.String accommodationSpotId,
                                                                                java.sql.Timestamp shipBeforeDate,
                                                                                java.sql.Timestamp shipAfterDate,
                                                                                java.sql.Timestamp reserveAfterDate,
                                                                                ProductConfigWrapper configWrapper,
                                                                                java.lang.String itemGroupNumber,
                                                                                java.util.Map<java.lang.String,​? extends java.lang.Object> context,
                                                                                java.lang.String parentProductId)
        Event to add an item to the shopping cart with accommodation.
      • addToCartFromOrder

        public java.util.Map<java.lang.String,​java.lang.Object> addToCartFromOrder​(java.lang.String catalogId,
                                                                                         java.lang.String orderId,
                                                                                         java.lang.String[] itemIds,
                                                                                         boolean addAll,
                                                                                         java.lang.String itemGroupNumber)
      • addToCartBulk

        public java.util.Map<java.lang.String,​java.lang.Object> addToCartBulk​(java.lang.String catalogId,
                                                                                    java.lang.String categoryId,
                                                                                    java.util.Map<java.lang.String,​? extends java.lang.Object> context)
        Adds all products in a category according to quantity request parameter for each; if no parameter for a certain product in the category, or if quantity is 0, do not add. If a _ign_${itemGroupNumber} is appended to the name it will be put in that group instead of the default in the request parameter in itemGroupNumber There are 2 options for the syntax: - name="quantity_${productId}" value="${quantity} - name="product_${whatever}" value="${productId}" (note: quantity is always 1)
      • addToCartBulkRequirements

        public java.util.Map<java.lang.String,​java.lang.Object> addToCartBulkRequirements​(java.lang.String catalogId,
                                                                                                java.util.Map<java.lang.String,​? extends java.lang.Object> context)
        Adds a set of requirements to the cart.
      • addCategoryDefaults

        public java.util.Map<java.lang.String,​java.lang.Object> addCategoryDefaults​(java.lang.String catalogId,
                                                                                          java.lang.String categoryId,
                                                                                          java.lang.String itemGroupNumber)
        Adds all products in a category according to default quantity on ProductCategoryMember for each; if no default for a certain product in the category, or if quantity is 0, do not add
      • deleteFromCart

        public java.util.Map<java.lang.String,​java.lang.Object> deleteFromCart​(java.util.Map<java.lang.String,​? extends java.lang.Object> context)
        Delete an item from the shopping cart.
      • modifyCart

        public java.util.Map<java.lang.String,​java.lang.Object> modifyCart​(Security security,
                                                                                 GenericValue userLogin,
                                                                                 java.util.Map<java.lang.String,​? extends java.lang.Object> context,
                                                                                 boolean removeSelected,
                                                                                 java.lang.String[] selectedItems,
                                                                                 java.util.Locale locale)
        Update the items in the shopping cart.
      • clearCart

        public boolean clearCart()
        Empty the shopping cart.
      • getCartObject

        public ShoppingCart getCartObject()
        Returns the shopping cart this helper is wrapping.
      • getFeatureAppl

        public GenericValue getFeatureAppl​(java.lang.String productId,
                                           java.lang.String optionField,
                                           java.lang.String featureId)
      • getRemoveFeatureTypeId

        public java.lang.String getRemoveFeatureTypeId​(java.lang.String optionField)
      • selectAgreement

        public java.util.Map<java.lang.String,​java.lang.Object> selectAgreement​(java.lang.String agreementId)
        Select an agreement
        Parameters:
        agreementId -
      • setCurrency

        public java.util.Map<java.lang.String,​java.lang.Object> setCurrency​(java.lang.String currencyUomId)
      • addOrderTerm

        public java.util.Map<java.lang.String,​java.lang.Object> addOrderTerm​(java.lang.String termTypeId,
                                                                                   java.math.BigDecimal termValue,
                                                                                   java.lang.Long termDays)
      • addOrderTerm

        public java.util.Map<java.lang.String,​java.lang.Object> addOrderTerm​(java.lang.String termTypeId,
                                                                                   java.math.BigDecimal termValue,
                                                                                   java.lang.Long termDays,
                                                                                   java.lang.String textValue)
      • removeOrderTerm

        public java.util.Map<java.lang.String,​java.lang.Object> removeOrderTerm​(int index)