This discussion is archived
1 2 Previous Next 16 Replies Latest reply: Nov 20, 2012 4:42 AM by 877508 Go to original post RSS
  • 15. Re: Many coupons in order
    973908 Newbie
    Currently Being Moderated
    Unfortunately, after override method claimCoupon() apply only first coupon code, not all. Are you have any ideas?

    Edited by: Yury Gerzhedovich on 19.11.2012 12:41
  • 16. Re: Many coupons in order
    877508 Newbie
    Currently Being Moderated
    Hi
    The code should work with a small correction I think the problem is that the second coupon is not valid and is therfore ending the transaction can you check , over ride claimCouponMethod in CouponFormHandler and write your own logic , you can obtain the coupons entered by the user and split them based on your delimiter.

    Also after you apply each coupon to the order by invoking claimCoupon method in ClaimableManager , do remember to reprice the oder and also update the order within a transaction block.
    You can also add the coupons which were not applied on the order ( may be due to conditions not matching , or non elgibility ) by checking the promodiscount amount on the order by iterating the commerce items (by getting the information from adjustments ).


    This could be a possible code block

    String[] coupons = inputCoupons.split("delimier used);
    //Begin Transaction
    for( String couponId:coupons){
    //get Coupons item

    //Begin Transaction

    getClaimableManager().claimCoupon(getProfile().getRepositoryId(),couponId);

    //End Transaction
    }

    //reprice the order using the pricing method chosen ( order_subtotal hencceforth)

    //update the order

    //end transaction

    by using a independent inner transaction , you can stop the entire transaction from being rolled back .

    Regards
    Sundar M R

    Edited by: Sundar on Nov 20, 2012 2:56 AM
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points