Interface PromotionResultService

    • Method Detail

      • isApplied

        boolean isApplied​(PromotionResultModel promotionResult)
        Returns true if the promotion fired and all of its actions have been applied to the order.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        Returns:
        Whether the promotion has been applied
      • isAppliedToOrder

        boolean isAppliedToOrder​(PromotionResultModel promotionResult)
        Returns true if the promotion fired and all of its actions have been applied to the order. This method checks that all the actions are still applied to the order.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        Returns:
        Whether the promotion has been applied
      • getFired

        boolean getFired​(PromotionResultModel promotionResult)
        Returns true if the promotion fired and has produced a result.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        Returns:
        Whether the promotion fired
      • getCouldFire

        boolean getCouldFire​(PromotionResultModel promotionResult)
        Is this a potential result. Returns true if the promotion believes it has a chance of firing, for instance if it requires 3 qualifying products but can only find 1.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        Returns:
        Whether the promotion could fire
      • getDescription

        java.lang.String getDescription​(PromotionResultModel promotionResult,
                                        java.util.Locale locale)
        Get the description of this promotion result. Gets the description for this promotion result. This description is based on the state of the result, the promotion that generated the result and the user supplied formatting strings.

        The Locale specified is used to format any numbers, dates or currencies for display to the user. It is important that this locale best represents the formatting options appropriate for display to the user. The default currency for the locale is ignored. The currency is always explicitly taken from the GeneratedAbstractOrder.getCurrency(). The currency is then formatted appropriately in the locale specified. For example, this does mean that values in the EURO currency will be formatted differently depending on the locale specified as each locale can specify currency specific formatting.

        The currency formatting is part of the Java VM configuration to support multiple locales. If the formatting is incorrect check your VM configuration for the locale and currency combination.

        Parameters:
        locale - The locale to use to format the messages. This locale must support currency formatting, i.e. this should be a region specific local. e.g de_DE, en_US, en_GB
        promotionResult - - instance of PromotionResultModel
        Returns:
        A description of the promotion result
      • apply

        boolean apply​(PromotionResultModel promotionResult)
        Apply all of the actions that this promotion generated to the order.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        Returns:
        true if calculateTotals() should be called to update the order totals.
      • undo

        boolean undo​(PromotionResultModel promotionResult)
        Undo all of the changes that this promotion made to the order.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        Returns:
        true if calculateTotals() should be called to update the order totals.
      • getConsumedCount

        long getConsumedCount​(PromotionResultModel promotionResult,
                              boolean includeCouldFirePromotions)
        Get the total number of items consumed by this promotion.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        includeCouldFirePromotions - include could fire promotions
        Returns:
        The total number of items consumed
      • getTotalDiscount

        double getTotalDiscount​(PromotionResultModel promotionResult)
        Get the total value of all discounts in this result. This result will be the same regardless of the applied state of this result, i.e. if not applied this is the discount value that would be applied, if it is applied then it is the value of the discount.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        Returns:
        The double value for the total discount value
      • getCouponCodesFromPromotion

        java.util.Optional<java.util.Set<java.lang.String>> getCouponCodesFromPromotion​(PromotionResultModel promotionResult)
        Return give way coupon code for promotion.
        Parameters:
        promotionResult - - instance of PromotionResultModel
        Returns:
        Optional Set of String containing give way coupon code