4 Replies Latest reply: Feb 8, 2013 10:14 AM by 989041 RSS

    Excluding specific SKU types while applying Order level discounts

    989041
      I am working on re-factoring coupons and promotions for my application using ATG 10, which was originally implemented in ATG 9. We have a business rule that specific SKU types should be ignored while calculating the promotion eligibility and also should be ignored while applying discounts.

      Is it possible to achieve this requirement by extending any OOTB calculators/qualifiers. Can anyone help me resolving the issue.

      Thanks.

      Satya
        • 1. Re: Excluding specific SKU types while applying Order level discounts
          Nooruddin Shaik
          Here is sample code:
          public class MyOrderPricingEngine extends OrderPricingEngineImpl{

          @Override
               protected Collection applyPromotions(Collection pPricingModels,
                         OrderPriceInfo pOrderPriceQuote, PricingContext pPricingContext,
                         Map pExtraParameters) throws PricingException {
                    Order order = pPricingContext.getOrder();
                    //find the commerceItems from order that belong to these skutypes
               forEach commerceItem order.getCommerceItem(pCommerceItemId);
          //find itemPriceTotal from all commerceItems removed and then adjust the price in OrdePriceInfo
                    double adjustedTotal = pOrderPriceQuote.getAmount() - itemPriceTotal;
                    double rawAdjustedTotal = pOrderPriceQuote.getRawSubtotal()
                              - itemPriceTotal;
                    Collection<RepositoryItem> returnedItem = super.applyPromotions(
                              pPricingModels, pOrderPriceQuote, pPricingContext,
                              pExtraParameters);
                    //addExludedItemsItemToOrderAndAjustPrice() // to add back the removed items back to order

                         pOrderPriceQuote.setAmount(pOrderPriceQuote.getAmount() + itemPriceTotal);
                         pOrderPriceQuote.setRawSubtotal( pOrderPriceQuote.getRawSubtotal() + itemPriceTotal);
                         
                    return returnedItem;
               }

          Let me know if you have any issues.

          Peace
          Shaik
          • 2. Re: Excluding specific SKU types while applying Order level discounts
            989041
            Hi SHaik,

            Thanks for your response. I have few questions on that implementation.

            In OOTB OrderDiscountCalculator class once priceOrder is executed, UpdateItemDiscountShare() method will be called and prorated discounts updated accordingly.

            If we update the order total as you mentioned, the prorated discount amount will also be applied on specific SKU types which i need to ignore. Any thoughts?

            -V@su
            • 3. Re: Excluding specific SKU types while applying Order level discounts
              Nooruddin Shaik
              When you remove the sku specific items from order, then these items are not available for prorated discounts.

              Peace
              Shaik
              • 4. Re: Excluding specific SKU types while applying Order level discounts
                989041
                For the pro-rated discounts updated getItemsToReceiveDiscountShare method in OrderDiscountCalculator class.

                Also added a new filter under qualifier and implemented filterItems (filterItemsForQualifier/filterItemsForTarget) methods and removed specific type of items from qualification in some discount types.

                V@su