Interface OfferProvider

  • All Known Implementing Classes:
    ExternalOfferProvider

    public interface OfferProvider
    Provider for interfacing with an Offer Engine that can supply discounts and promotions base on the contents of a Cart.
    Author:
    Chad Harchar (charchar)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void applyOffers​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean runOrderAndItemOffers, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Handles requests against the Offer Engine to retrieve and apply discounts for a Cart and its contents.
      void applyOffers​(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Handles requests against the Offer Engine to retrieve and apply discounts for a Cart and its contents.
      String getCodeUsabilityType​(String code, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Determines the usability type of the promo code in the context of the given cart.
      com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult validateOfferAndOfferCodeUsages​(com.broadleafcommerce.cart.client.domain.Cart cart, List<String> offerCodes, List<String> offerRefIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Retrieve validation information regarding the cart's usage of the provided offers and offer codes to determine if the usage is still valid.
    • Method Detail

      • applyOffers

        void applyOffers​(com.broadleafcommerce.cart.client.domain.Cart cart,
                         @Nullable
                         com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Handles requests against the Offer Engine to retrieve and apply discounts for a Cart and its contents. This method should apply all kinds of offers applicable to the contents including all order, order item, fulfillment, and fulfillment item offers.

        To control whether order and order item offers are applied use applyOffers(Cart, boolean, ContextInfo) and set `runOrderAndItemOffers` as desired. Set it to false if you only want to run fulfillment and fulfillment item offers. By default, fulfillment pricing occurs after order and order items have been priced and their offers applied since fulfillment pricing and promotions can depend on the price of the merchandise being fulfilled.

        Parameters:
        cart - The Cart whose contents to send to the offer engine for evaluation
        contextInfo - Additional sandbox and tenancy info
      • applyOffers

        void applyOffers​(@NonNull
                         @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                         boolean runOrderAndItemOffers,
                         @Nullable
                         com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Handles requests against the Offer Engine to retrieve and apply discounts for a Cart and its contents. Allows specifying whether order and order item offers will be applied in the calculation. Set runOrderAndItemOffers to false if you only want to run fulfillment and fulfillment item offers.

        By default, fulfillment pricing occurs after order and order items have been priced and their offers applied since fulfillment pricing and promotions can depend on the price of the merchandise being fulfilled. Thus, when fulfillment offers are processed, order and order item offers should not also be reprocessed or the results can be incorrect—this also makes the request run faster since only fulfillment will be considered.

        Parameters:
        cart - The Cart whose contents to send to the offer engine for evaluation
        runOrderAndItemOffers - Whether to have the Offer Engine run order and order item level offers. Set this to false if you only want to run fulfillment and fulfillment item offers. By default, fulfillment pricing occurs after order and order items have been priced and their offers applied since fulfillment pricing and promotions can depend on the price of the merchandise being fulfilled.
        contextInfo - Additional sandbox and tenancy info
      • getCodeUsabilityType

        String getCodeUsabilityType​(String code,
                                    com.broadleafcommerce.cart.client.domain.Cart cart,
                                    @Nullable
                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Determines the usability type of the promo code in the context of the given cart. Possible values are defined in CodeUsabilityType and include whether the code is usable, cannot be used because it has reached its max uses limit, or cannot be used because it does not match any offers (may be a campaign code or some other type in this case).
        Parameters:
        code - The promo code to apply to cart
        cart - The Cart that promo code is to be applied to
        contextInfo - Additional sandbox and tenancy info
        Returns:
        The usability type
        See Also:
        CodeUsabilityType
      • validateOfferAndOfferCodeUsages

        com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult validateOfferAndOfferCodeUsages​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                                                                                        List<String> offerCodes,
                                                                                                                                        List<String> offerRefIds,
                                                                                                                                        @Nullable
                                                                                                                                        com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Retrieve validation information regarding the cart's usage of the provided offers and offer codes to determine if the usage is still valid.
        Parameters:
        cart - The cart against which to validate offer and code uses.
        offerCodes - The codes to check for validity.
        offerRefIds - The offer ids to check for validity.
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        A validation result that holds information about which offer & offer code usages are invalid and why