Package de.hybris.platform.order.impl
Class DefaultCartService
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.service.AbstractService
-
- de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
-
- de.hybris.platform.order.impl.DefaultAbstractOrderService<CartModel,CartEntryModel>
-
- de.hybris.platform.order.impl.DefaultCartService
-
- All Implemented Interfaces:
AbstractOrderService<CartModel,CartEntryModel>,CartService,java.io.Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
DefaultB2BCartService,DefaultCartServiceForAccelerator
public class DefaultCartService extends DefaultAbstractOrderService<CartModel,CartEntryModel> implements CartService
Default implementation of theCartService- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSESSION_CART_PARAMETER_NAME-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManager
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant
-
-
Constructor Summary
Constructors Constructor Description DefaultCartService()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddToCart(CartModel cartModel, ProductModel productModel, long quantity, UnitModel unitModel)Deprecated.since 6.2.0voidappendToCart(CartModel sourceCart, CartModel targetCart)Clones all entries of source cart to the target cart.booleancalculateCart(CartModel cartModel)Deprecated.since 6.2.0voidchangeCurrentCartUser(UserModel user)Changes the user of the session cart to the given user.voidchangeSessionCartCurrency(CurrencyModel currency)Changes the currency of the session cart to the given currency.CartModelclone(ComposedTypeModel orderType, ComposedTypeModel entryType, AbstractOrderModel original, java.lang.String code)Creates new order from given original and change its type and type for entry.CartModelcreateCartFromQuote(QuoteModel quote)Creates a new cart based on the givenQuoteModel.protected CreateCartFromQuoteStrategygetCreateCartFromQuoteStrategy()protected intgetNextEntryNumber(CartModel cart, AbstractOrderEntryModel forMe)CartModelgetSessionCart()Returns the cart attached to the current session.booleanhasCart()Deprecated.since 6.2.0booleanhasSessionCart()Returnstrueif the current session already holds a cart,falseotherwise.protected CartModelinternalGetSessionCart()protected voidpostProcessClonedEntries(java.util.Collection<CartEntryModel> sourceClones, int lastEntryNo, CartModel targetCart)Rearrange cloned entries numbers according to last entry number from the target.voidremoveSessionCart()If existing the current session cart is being detached from this session and removed.voidsetAddToCartStrategy(AddToCartStrategy addToCartStrategy)voidsetCartFactory(CartFactory cartFactory)voidsetCreateCartFromQuoteStrategy(CreateCartFromQuoteStrategy createCartFromQuoteStrategy)voidsetOrderCalculation(OrderCalculation orderCalculation)voidsetSessionCart(CartModel cart)Attach the cart to a session.voidupdateQuantities(CartModel cart, java.util.List<java.lang.Long> quantities)Deprecated.since 6.2.0voidupdateQuantities(CartModel cart, java.util.Map<java.lang.Integer,java.lang.Long> quantities)Updates multiple cart entry quantities at once.-
Methods inherited from class de.hybris.platform.order.impl.DefaultAbstractOrderService
addAllGlobalDiscountValues, addAllTotalTaxValues, addEntryAtPosition, addGlobalDiscountValue, addNewEntry, addNewEntry, addNewEntry, addTotalTaxValue, getAbstractOrderEntryService, getAbstractOrderEntryTypeService, getCloneAbstractOrderStrategy, getCollidingEntry, getEntriesForNumber, getEntriesForProduct, getEntryForNumber, getEntryTypeCode, getGlobalDiscountValue, getOrderDao, getSaveAbstractOrderStrategy, removeGlobalDiscountValue, removeTotalTaxValue, saveOrder, setAbstractOrderEntryService, setAbstractOrderEntryTypeService, setCloneAbstractOrderStrategy, setOrderDao, setSaveAbstractOrderStrategy
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManager
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.order.AbstractOrderService
addAllGlobalDiscountValues, addAllTotalTaxValues, addGlobalDiscountValue, addNewEntry, addNewEntry, addNewEntry, addTotalTaxValue, getEntriesForNumber, getEntriesForProduct, getEntryForNumber, getGlobalDiscountValue, removeGlobalDiscountValue, removeTotalTaxValue, saveOrder
-
-
-
-
Field Detail
-
SESSION_CART_PARAMETER_NAME
public static final java.lang.String SESSION_CART_PARAMETER_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
addToCart
@Deprecated public void addToCart(CartModel cartModel, ProductModel productModel, long quantity, UnitModel unitModel) throws InvalidCartException
Deprecated.since 6.2.0Description copied from interface:CartServiceAdds to the (existing)CartModelthe (existing)ProductModelin the givenUnitModeland with the givenquantity. If in the cart already an entry with the given product and given unit exists the givenquantityis added to the the quantity of this cart entry. After this the cart is calculated.- Specified by:
addToCartin interfaceCartService- Parameters:
cartModel- the cart, must existproductModel- the product which is added to the cartquantity- the quantity of the productunitModel- ifnullProductService.getOrderableUnit(ProductModel)is used to determine the unit- Throws:
InvalidCartException- if theproductis a base product OR the quantity is less 1 or no usable unit was found (only when givenunitis alsonull)
-
hasSessionCart
public boolean hasSessionCart()
Description copied from interface:CartServiceReturnstrueif the current session already holds a cart,falseotherwise. Please use this instead ofCartService.getSessionCart()if you like to avoid unnecessary auto-creation of the session cart.- Specified by:
hasSessionCartin interfaceCartService- See Also:
CartService.getSessionCart()
-
hasCart
@Deprecated public boolean hasCart()
Deprecated.since 6.2.0- Specified by:
hasCartin interfaceCartService
-
setSessionCart
public void setSessionCart(CartModel cart)
Description copied from interface:CartServiceAttach the cart to a session. Please not that a previously existing session cart is being detached and remove during that operation. It will no longer be available afterwards.- Specified by:
setSessionCartin interfaceCartService
-
getSessionCart
public CartModel getSessionCart()
Description copied from interface:CartServiceReturns the cart attached to the current session. The session cart is, just like current user, current currency or language, a part of session data that lives in the session scope.If there is no cart attached to the current session yet, this method will automatically create a new cart and attaches it to the current session.
The creation process is performed by the injected
CartFactory. As default aDefaultCartFactoryis being used.- Specified by:
getSessionCartin interfaceCartService
-
internalGetSessionCart
protected CartModel internalGetSessionCart()
-
calculateCart
@Deprecated public boolean calculateCart(CartModel cartModel)
Deprecated.since 6.2.0Description copied from interface:CartServiceCalculates the givencartModeland returnstrueif each entry and after this theCartModelwas calculated. Thereby any invalid entry will be automatically removed.- Specified by:
calculateCartin interfaceCartService- Parameters:
cartModel- theCartModel- Returns:
falseif thecartModelwas already calculated.
-
updateQuantities
@Deprecated public void updateQuantities(CartModel cart, java.util.List<java.lang.Long> quantities)
Deprecated.since 6.2.0Description copied from interface:CartServiceUpdates the quantities of each cart entry with the list ofquantities. If the quantity value is 0 the cart entry is removed.- Specified by:
updateQuantitiesin interfaceCartService- Parameters:
cart- the cart where the quantities are updatedquantities- the new quantity list for each cart entry
-
updateQuantities
public void updateQuantities(CartModel cart, java.util.Map<java.lang.Integer,java.lang.Long> quantities)
Description copied from interface:CartServiceUpdates multiple cart entry quantities at once. Entries that receive a quantity < 1 will be removed as well as entries that receive NULL as quantity value. Refreshes a given cart instance after that.Entries with entry numbers that do not occur in the parameter map are not touched.
- Specified by:
updateQuantitiesin interfaceCartService- Parameters:
cart- the cart to update cart entry quantities atquantities- the entry specific quantities as map of { entry number -> quantity }
-
removeSessionCart
public void removeSessionCart()
Description copied from interface:CartServiceIf existing the current session cart is being detached from this session and removed. Afterwards it's no longer available.- Specified by:
removeSessionCartin interfaceCartService- See Also:
CartService.getSessionCart(),CartService.setSessionCart(CartModel)
-
clone
public CartModel clone(ComposedTypeModel orderType, ComposedTypeModel entryType, AbstractOrderModel original, java.lang.String code)
Description copied from interface:AbstractOrderServiceCreates new order from given original and change its type and type for entry. Delegates to the specificCloneAbstractOrderStrategyinjected strategy. Resulting order remains not persisted.- Specified by:
clonein interfaceAbstractOrderService<CartModel,CartEntryModel>- Parameters:
orderType- type of result order (OrderModel will be chosen if null is passed)entryType- type of entry (if null will use service to get proper type)original- original ordercode- code for new order- Returns:
- not persisted order model instance.
-
appendToCart
public void appendToCart(CartModel sourceCart, CartModel targetCart)
Description copied from interface:CartServiceClones all entries of source cart to the target cart. After this call, the target cart needs recalculation. To do it, useCalculationService. The target cart is also not persisted after this method call.- Specified by:
appendToCartin interfaceCartService- Parameters:
sourceCart- the cart providing the entries to copytargetCart- the target cart to create new entries for
-
changeCurrentCartUser
public void changeCurrentCartUser(UserModel user)
Description copied from interface:CartServiceChanges the user of the session cart to the given user. Please mind that the session cart may need recalculation after this call, as the price discounts may be user dependent. In case there is no session cart at the time of this method call, one will be created.- Specified by:
changeCurrentCartUserin interfaceCartService- Parameters:
user- new session cart user
-
postProcessClonedEntries
protected void postProcessClonedEntries(java.util.Collection<CartEntryModel> sourceClones, int lastEntryNo, CartModel targetCart)
Rearrange cloned entries numbers according to last entry number from the target.
-
getNextEntryNumber
protected int getNextEntryNumber(CartModel cart, AbstractOrderEntryModel forMe)
-
setAddToCartStrategy
public void setAddToCartStrategy(AddToCartStrategy addToCartStrategy)
-
setOrderCalculation
public void setOrderCalculation(OrderCalculation orderCalculation)
-
setCartFactory
public void setCartFactory(CartFactory cartFactory)
-
changeSessionCartCurrency
public void changeSessionCartCurrency(CurrencyModel currency)
Description copied from interface:CartServiceChanges the currency of the session cart to the given currency. Please mind that the session cart need recalculation after this call. In case there is no session cart at the time of this method call, one will be created.- Specified by:
changeSessionCartCurrencyin interfaceCartService- Parameters:
currency- new session cart currency
-
createCartFromQuote
public CartModel createCartFromQuote(QuoteModel quote)
Description copied from interface:CartServiceCreates a new cart based on the givenQuoteModel. Please note that it is the caller's responsibility to persist the new cart returned by this method. The quote passed into this method will not be affected by its logic.- Specified by:
createCartFromQuotein interfaceCartService- Parameters:
quote- the quote model- Returns:
- the new cart model
-
getCreateCartFromQuoteStrategy
protected CreateCartFromQuoteStrategy getCreateCartFromQuoteStrategy()
-
setCreateCartFromQuoteStrategy
public void setCreateCartFromQuoteStrategy(CreateCartFromQuoteStrategy createCartFromQuoteStrategy)
-
-