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,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 the
CartService- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO -
Field Summary
FieldsFields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManagerFields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToCart(CartModel cartModel, ProductModel productModel, long quantity, UnitModel unitModel) Deprecated, for removal: This API element is subject to removal in a future version.since 6.2.0voidappendToCart(CartModel sourceCart, CartModel targetCart) Clones all entries of source cart to the target cart.booleancalculateCart(CartModel cartModel) Deprecated, for removal: This API element is subject to removal in a future version.since 6.2.0voidChanges the user of the session cart to the given user.voidchangeSessionCartCurrency(CurrencyModel currency) Changes the currency of the session cart to the given currency.clone(ComposedTypeModel orderType, ComposedTypeModel entryType, AbstractOrderModel original, String code) Creates new order from given original and change its type and type for entry.createCartFromQuote(QuoteModel quote) Creates a new cart based on the givenQuoteModel.protected CreateCartFromQuoteStrategyprotected intgetNextEntryNumber(CartModel cart, AbstractOrderEntryModel forMe) Returns the cart attached to the current session.booleanhasCart()Deprecated, for removal: This API element is subject to removal in a future version.since 6.2.0booleanReturnstrueif the current session already holds a cart,falseotherwise.protected CartModelprotected voidpostProcessClonedEntries(Collection<CartEntryModel> sourceClones, int lastEntryNo, CartModel targetCart) Rearrange cloned entries numbers according to last entry number from the target.voidIf 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, List<Long> quantities) Deprecated, for removal: This API element is subject to removal in a future version.since 6.2.0voidupdateQuantities(CartModel cart, Map<Integer, 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, setSaveAbstractOrderStrategyMethods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerMethods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplaceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.hybris.platform.order.AbstractOrderService
addAllGlobalDiscountValues, addAllTotalTaxValues, addGlobalDiscountValue, addNewEntry, addNewEntry, addNewEntry, addTotalTaxValue, getEntriesForNumber, getEntriesForProduct, getEntryForNumber, getGlobalDiscountValue, removeGlobalDiscountValue, removeTotalTaxValue, saveOrder
-
Field Details
-
SESSION_CART_PARAMETER_NAME
- See Also:
-
-
Constructor Details
-
DefaultCartService
public DefaultCartService()
-
-
Method Details
-
addToCart
@Deprecated(since="6.2.0", forRemoval=true) public void addToCart(CartModel cartModel, ProductModel productModel, long quantity, UnitModel unitModel) throws InvalidCartException Deprecated, for removal: This API element is subject to removal in a future version.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:
-
hasCart
Deprecated, for removal: This API element is subject to removal in a future version.since 6.2.0- Specified by:
hasCartin interfaceCartService
-
setSessionCart
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
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
-
calculateCart
Deprecated, for removal: This API element is subject to removal in a future version.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(since="6.2.0", forRemoval=true) public void updateQuantities(CartModel cart, List<Long> quantities) Deprecated, for removal: This API element is subject to removal in a future version.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
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:
-
clone
public CartModel clone(ComposedTypeModel orderType, ComposedTypeModel entryType, AbstractOrderModel original, 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
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
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(Collection<CartEntryModel> sourceClones, int lastEntryNo, CartModel targetCart) Rearrange cloned entries numbers according to last entry number from the target. -
getNextEntryNumber
-
setAddToCartStrategy
-
setOrderCalculation
-
setCartFactory
-
changeSessionCartCurrency
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
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
-
setCreateCartFromQuoteStrategy
-