Class DefaultSubscriptionCommerceCartService
- java.lang.Object
-
- de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService
-
- de.hybris.platform.subscriptionservices.subscription.impl.DefaultSubscriptionCommerceCartService
-
- All Implemented Interfaces:
CommerceCartService,SubscriptionCommerceCartService
public class DefaultSubscriptionCommerceCartService extends DefaultCommerceCartService implements SubscriptionCommerceCartService
Default implementation ofSubscriptionCommerceCartService.
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService
ESTIMATED_TAXES
-
-
Constructor Summary
Constructors Constructor Description DefaultSubscriptionCommerceCartService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddOneRecurringFrequency(SubscriptionPricePlanModel subscriptionPricePlan, java.util.List<BillingTimeModel> billingFrequencies)voidcheckMasterCart(CartModel cartModel, BillingTimeModel masterCartBillingTimeModel)Checks if the givenCartModelis a master cart and has the correctBillingTimeModel.voidcheckQuantityToAdd(long quantityToAdd)Checks if given quantity can be added.protected voidcheckQuantityToAdd(long quantityToAdd, long maxQuantity)CartModelcreateChildCartForBillingTime(CartModel masterCart, BillingTimeModel billFreq)Creates a new child cart for the given billing frequency and assigns it as child cart to the given master cart.protected longgetAvailableStockLevel(ProductModel productModel, PointOfServiceModel pointOfServiceModel)Find the available stock quantity for a product.protected BaseStoreServicegetBaseStoreService()java.util.List<BillingTimeModel>getBillingFrequenciesForMasterEntry(AbstractOrderEntryModel entry)Get billing frequencies for the master entry.protected BillingTimeModelgetBillingTimeForCode(java.lang.String code)protected BillingTimeServicegetBillingTimeService()protected AbstractOrderEntryModelgetCartEntryToBeUpdated(CartModel cartModel, long entryNumber)Searches in the givencartModelfor the cart entry with has the givenentryNumberand returns it.CartModelgetChildCartForBillingTime(CartModel masterCart, BillingTimeModel billFreq)Get the child cart for the givenBillingTimeModel, if any.protected SubscriptionCommercePriceServicegetCommercePriceService()protected CommerceStockServicegetCommerceStockService()java.lang.StringgetMasterCartBillingTimeCode()Get the billing frequency code for the master cart.CartModelgetMasterCartForCartEntry(CartEntryModel cartEntryModel)Get the master cart for the givencartEntryModel.protected SubscriptionCommerceCartStrategygetSubscriptionCommerceCartStrategy()protected SubscriptionProductServicegetSubscriptionProductService()protected intgetSubscriptionProductStockQuantity()protected booleanisMasterCart(CartModel cartModel)voidrecalculateCart(CommerceCartParameter parameter)Overrides the super class' method to make sure that in a multi-cart system the master cart and its child carts are re-calculated.voidrecalculateCart(CartModel masterCartModel)Overrides the super class' method to make sure that in a multi-cart system the master cart and its child carts are re-calculated.voidremoveAllEntries(CartModel masterCartModel)voidsetBaseStoreService(BaseStoreService baseStoreService)voidsetBillingTimeService(BillingTimeService billingTimeService)voidsetCommercePriceService(SubscriptionCommercePriceService commercePriceService)voidsetCommerceStockService(CommerceStockService commerceStockService)voidsetMasterCartBillingTimeCode(java.lang.String masterCartBillingTimeCode)voidsetSubscriptionCommerceCartStrategy(SubscriptionCommerceCartStrategy subscriptionCommerceCartStrategy)voidsetSubscriptionProductService(SubscriptionProductService subscriptionProductService)voidsetSubscriptionProductStockQuantity(int subscriptionProductStockQuantity)protected booleanuseBillingFrequencyForProduct(ProductModel subscriptionProduct, SubscriptionPricePlanModel subscriptionPricePlan)-
Methods inherited from class de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService
addToCart, addToCart, addToCart, afterCalculate, beforeCalculate, calculateCart, calculateCart, configureCartEntry, estimateTaxes, estimateTaxes, getBaseSiteService, getCartForCodeAndUser, getCartForGuidAndSite, getCartForGuidAndSiteAndUser, getCartsForSiteAndUser, getCartValidationStrategy, getCommerceAddToCartStrategy, getCommerceCartCalculationStrategy, getCommerceCartDao, getCommerceCartEstimateTaxesStrategy, getCommerceCartHashCalculationStrategy, getCommerceCartMergingStrategy, getCommerceCartMetadataUpdateStrategy, getCommerceCartRestorationStrategy, getCommerceCartSplitStrategy, getCommerceRemoveEntriesStrategy, getCommerceUpdateCartEntryStrategy, getModelService, getProductConfigurationStrategy, getRemoveEntryGroupStrategy, getSessionService, getStaleCartRemovalStrategy, mergeCarts, removeAllEntries, removeEntryGroup, removeStaleCarts, removeStaleCarts, restoreCart, restoreCart, setBaseSiteService, setCartValidationStrategy, setCommerceAddToCartStrategy, setCommerceCartCalculationStrategy, setCommerceCartDao, setCommerceCartEstimateTaxesStrategy, setCommerceCartHashCalculationStrategy, setCommerceCartMergingStrategy, setCommerceCartMetadataUpdateStrategy, setCommerceCartRestorationStrategy, setCommerceCartSplitStrategy, setCommerceRemoveEntriesStrategy, setCommerceUpdateCartEntryStrategy, setModelService, setProductConfigurationStrategy, setRemoveEntryGroupStrategy, setSessionService, setStaleCartRemovalStrategy, split, split, updateCartMetadata, updatePointOfServiceForCartEntry, updatePointOfServiceForCartEntry, updateQuantityForCartEntry, updateQuantityForCartEntry, updateToShippingModeForCartEntry, updateToShippingModeForCartEntry, validateCart, validateCart
-
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.commerceservices.order.CommerceCartService
addToCart, addToCart, addToCart, calculateCart, calculateCart, configureCartEntry, estimateTaxes, estimateTaxes, getCartForCodeAndUser, getCartForGuidAndSite, getCartForGuidAndSiteAndUser, getCartsForSiteAndUser, mergeCarts, removeAllEntries, removeEntryGroup, removeStaleCarts, removeStaleCarts, restoreCart, restoreCart, split, split, updateCartMetadata, updatePointOfServiceForCartEntry, updatePointOfServiceForCartEntry, updateQuantityForCartEntry, updateQuantityForCartEntry, updateToShippingModeForCartEntry, updateToShippingModeForCartEntry, validateCart, validateCart
-
-
-
-
Method Detail
-
getBillingFrequenciesForMasterEntry
@Nonnull public java.util.List<BillingTimeModel> getBillingFrequenciesForMasterEntry(@Nonnull AbstractOrderEntryModel entry)
Description copied from interface:SubscriptionCommerceCartServiceGet billing frequencies for the master entry.- Specified by:
getBillingFrequenciesForMasterEntryin interfaceSubscriptionCommerceCartService- Parameters:
entry-AbstractOrderEntryModelto get list of billing frequencies for- Returns:
- List of
BillingTimeModels
-
addOneRecurringFrequency
protected void addOneRecurringFrequency(SubscriptionPricePlanModel subscriptionPricePlan, java.util.List<BillingTimeModel> billingFrequencies)
-
useBillingFrequencyForProduct
protected boolean useBillingFrequencyForProduct(ProductModel subscriptionProduct, SubscriptionPricePlanModel subscriptionPricePlan)
-
removeAllEntries
public void removeAllEntries(CartModel masterCartModel)
- Specified by:
removeAllEntriesin interfaceCommerceCartService- Overrides:
removeAllEntriesin classDefaultCommerceCartService- Parameters:
masterCartModel- the user's cart in session
-
getCartEntryToBeUpdated
protected AbstractOrderEntryModel getCartEntryToBeUpdated(CartModel cartModel, long entryNumber) throws CommerceCartModificationException
Searches in the givencartModelfor the cart entry with has the givenentryNumberand returns it.- Parameters:
cartModel- the cartentryNumber- number of the cart entry- Returns:
- the cart entry with the given
entryNumber - Throws:
CommerceCartModificationException- if there is no cart entry with the givenentryNumber
-
getAvailableStockLevel
protected long getAvailableStockLevel(ProductModel productModel, PointOfServiceModel pointOfServiceModel)
Find the available stock quantity for a product. Overrides the method in the super class in order to handle stock availability also for subscription products which do not have a physically available stock- Parameters:
productModel- the product in the cart- Returns:
- the available stock level
-
getChildCartForBillingTime
@Nullable public CartModel getChildCartForBillingTime(@Nonnull CartModel masterCart, @Nonnull BillingTimeModel billFreq)
Description copied from interface:SubscriptionCommerceCartServiceGet the child cart for the givenBillingTimeModel, if any.- Specified by:
getChildCartForBillingTimein interfaceSubscriptionCommerceCartService- Parameters:
masterCart- theCartModelof the master cartbillFreq- theBillingTimeModelto look for- Returns:
- the
CartModelfor the givenBillingTimeModelor null.
-
createChildCartForBillingTime
public CartModel createChildCartForBillingTime(CartModel masterCart, BillingTimeModel billFreq)
Creates a new child cart for the given billing frequency and assigns it as child cart to the given master cart.- Specified by:
createChildCartForBillingTimein interfaceSubscriptionCommerceCartService- Parameters:
masterCart-CartModelrepresenting master cart for which child cart should be createdbillFreq-BillingTimeModelfor child cart- Returns:
- Created child cart.
-
isMasterCart
protected boolean isMasterCart(CartModel cartModel)
-
checkMasterCart
public void checkMasterCart(CartModel cartModel, BillingTimeModel masterCartBillingTimeModel) throws java.lang.IllegalArgumentException, CommerceCartModificationException
Checks if the givenCartModelis a master cart and has the correctBillingTimeModel.- Specified by:
checkMasterCartin interfaceSubscriptionCommerceCartService- Parameters:
cartModel- the cart model to be checked whether it is a master cartmasterCartBillingTimeModel- theBillingTimeModelthat a master cart must have. If the given cart's billing frequency is empty themasterCartBillingTimeModelwill be set as billing frequency- Throws:
java.lang.IllegalArgumentException- if the given cart is not a master cartCommerceCartModificationException- if the given cart's billing frequency does no equal the givenmasterCartBillingTimeModel
-
recalculateCart
public void recalculateCart(CartModel masterCartModel) throws CalculationException
Overrides the super class' method to make sure that in a multi-cart system the master cart and its child carts are re-calculated. This includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed price factory.- Specified by:
recalculateCartin interfaceCommerceCartService- Overrides:
recalculateCartin classDefaultCommerceCartService- Parameters:
masterCartModel- the cart modelCartModel(must exist) that will be recalculatedCartModel. It must be the master cart of the multi-cart system. In addition, the master cart's child carts will also be re-calculated.- Throws:
java.lang.IllegalArgumentException- in case the givenmasterCartModelis not a master cartCalculationException
-
recalculateCart
public void recalculateCart(CommerceCartParameter parameter)
Overrides the super class' method to make sure that in a multi-cart system the master cart and its child carts are re-calculated. This includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed price factory.- Specified by:
recalculateCartin interfaceCommerceCartService- Overrides:
recalculateCartin classDefaultCommerceCartService- Parameters:
parameter- checkout parameter containing the the master cart of the multi-cart
-
getMasterCartForCartEntry
@Nonnull public CartModel getMasterCartForCartEntry(@Nonnull CartEntryModel cartEntryModel)
Description copied from interface:SubscriptionCommerceCartServiceGet the master cart for the givencartEntryModel. ThecartEntryModelmay be a master or child cart entry.- Specified by:
getMasterCartForCartEntryin interfaceSubscriptionCommerceCartService- Parameters:
cartEntryModel- theCartEntryModelwhose masterCartModelis searched- Returns:
- the given
cartEntryModel's masterCartModel
-
checkQuantityToAdd
protected void checkQuantityToAdd(long quantityToAdd, long maxQuantity) throws CommerceCartModificationException
-
checkQuantityToAdd
public void checkQuantityToAdd(long quantityToAdd) throws CommerceCartModificationExceptionDescription copied from interface:SubscriptionCommerceCartServiceChecks if given quantity can be added.- Specified by:
checkQuantityToAddin interfaceSubscriptionCommerceCartService- Parameters:
quantityToAdd- quantyty to add- Throws:
CommerceCartModificationException- If given quantity is not allowed to add.
-
getBillingTimeForCode
protected BillingTimeModel getBillingTimeForCode(java.lang.String code)
-
setMasterCartBillingTimeCode
public void setMasterCartBillingTimeCode(java.lang.String masterCartBillingTimeCode)
-
getMasterCartBillingTimeCode
public java.lang.String getMasterCartBillingTimeCode()
Description copied from interface:SubscriptionCommerceCartServiceGet the billing frequency code for the master cart.- Specified by:
getMasterCartBillingTimeCodein interfaceSubscriptionCommerceCartService- Returns:
- a String with the billing frequency code for the master cart
-
setBillingTimeService
public void setBillingTimeService(BillingTimeService billingTimeService)
-
getBillingTimeService
protected BillingTimeService getBillingTimeService()
-
setSubscriptionProductStockQuantity
public void setSubscriptionProductStockQuantity(int subscriptionProductStockQuantity)
-
getSubscriptionProductStockQuantity
protected int getSubscriptionProductStockQuantity()
-
getCommercePriceService
protected SubscriptionCommercePriceService getCommercePriceService()
-
setCommercePriceService
public void setCommercePriceService(SubscriptionCommercePriceService commercePriceService)
-
getSubscriptionCommerceCartStrategy
protected SubscriptionCommerceCartStrategy getSubscriptionCommerceCartStrategy()
-
setSubscriptionCommerceCartStrategy
public void setSubscriptionCommerceCartStrategy(SubscriptionCommerceCartStrategy subscriptionCommerceCartStrategy)
-
getBaseStoreService
protected BaseStoreService getBaseStoreService()
-
setBaseStoreService
public void setBaseStoreService(BaseStoreService baseStoreService)
-
getCommerceStockService
protected CommerceStockService getCommerceStockService()
-
setCommerceStockService
public void setCommerceStockService(CommerceStockService commerceStockService)
-
getSubscriptionProductService
protected SubscriptionProductService getSubscriptionProductService()
- Returns:
- subscription product service
-
setSubscriptionProductService
public void setSubscriptionProductService(SubscriptionProductService subscriptionProductService)
-
-