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 of
SubscriptionCommerceCartService.-
Field Summary
Fields inherited from class de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService
ESTIMATED_TAXES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddOneRecurringFrequency(SubscriptionPricePlanModel subscriptionPricePlan, 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) 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.protected longgetAvailableStockLevel(ProductModel productModel, PointOfServiceModel pointOfServiceModel) Find the available stock quantity for a product.protected BaseStoreServiceGet billing frequencies for the master entry.protected BillingTimeModelgetBillingTimeForCode(String code) protected BillingTimeServiceprotected AbstractOrderEntryModelgetCartEntryToBeUpdated(CartModel cartModel, long entryNumber) Searches in the givencartModelfor the cart entry with has the givenentryNumberand returns it.getChildCartForBillingTime(CartModel masterCart, BillingTimeModel billFreq) Get the child cart for the givenBillingTimeModel, if any.protected SubscriptionCommercePriceServiceprotected CommerceStockServiceGet the billing frequency code for the master cart.getMasterCartForCartEntry(CartEntryModel cartEntryModel) Get the master cart for the givencartEntryModel.protected SubscriptionCommerceCartStrategyprotected SubscriptionProductServiceprotected intprotected 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(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, validateCartMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
-
Constructor Details
-
DefaultSubscriptionCommerceCartService
public DefaultSubscriptionCommerceCartService()
-
-
Method Details
-
getBillingFrequenciesForMasterEntry
@Nonnull public 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, List<BillingTimeModel> billingFrequencies) -
useBillingFrequencyForProduct
protected boolean useBillingFrequencyForProduct(ProductModel subscriptionProduct, SubscriptionPricePlanModel subscriptionPricePlan) -
removeAllEntries
- 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
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
-
checkMasterCart
public void checkMasterCart(CartModel cartModel, BillingTimeModel masterCartBillingTimeModel) throws 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:
IllegalArgumentException- if the given cart is not a master cartCommerceCartModificationException- if the given cart's billing frequency does no equal the givenmasterCartBillingTimeModel
-
recalculateCart
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:
IllegalArgumentException- in case the givenmasterCartModelis not a master cartCalculationException
-
recalculateCart
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
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
Description 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
-
setMasterCartBillingTimeCode
-
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
-
getBillingTimeService
-
setSubscriptionProductStockQuantity
public void setSubscriptionProductStockQuantity(int subscriptionProductStockQuantity) -
getSubscriptionProductStockQuantity
protected int getSubscriptionProductStockQuantity() -
getCommercePriceService
-
setCommercePriceService
-
getSubscriptionCommerceCartStrategy
-
setSubscriptionCommerceCartStrategy
public void setSubscriptionCommerceCartStrategy(SubscriptionCommerceCartStrategy subscriptionCommerceCartStrategy) -
getBaseStoreService
-
setBaseStoreService
-
getCommerceStockService
-
setCommerceStockService
-
getSubscriptionProductService
- Returns:
- subscription product service
-
setSubscriptionProductService
-