Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Vineeth 71 posts 291 karma points
    Jan 28, 2019 @ 09:26
    Vineeth
    0

    How to validate and get Discount Coupons

    We need to add discount coupons on our product details page before adding it to the cart. So how can we validate and get the coupons added in the Discount code rule on before adding an orderline ?

    We need to apply the discount coupons generated in the Discount code rule on the product detail page. How can we validate the coupons, get the percentage or amount given for the coupons?

    We need to show the discounted price on the frontend when we apply the coupon code on the product detail page, Not in the cart page. Can you please help?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 28, 2019 @ 09:57
    Matt Brailsford
    1

    Hi @Vineeth

    This kind of depends how you are applying the discounts. I'm guessing by your other post you aren't using the standard discount codes feature.

    Either way, when working outside of the cart context then any price displays are down to the developer to work out as Tea Commerce will only assist once the product is in the order.

    If you have a discount applied to the order already, then you would likely need to look through your order object and see if a discount is applied and if so, get the discount and run the discount calculation manually against the price stored on the content node. Unfortunately we don't really have an API for calling the calculation, so you'd likely have to do the calculation yourself.

    Does that answer your question?

    Many thanks

    Matt

  • Vineeth 71 posts 291 karma points
    Jan 28, 2019 @ 10:45
    Vineeth
    0

    Hi @Matt

    Yeah, it makes sense and Thanks. But if I use the discount code rule on Tea commerce. Can I get the discount coupons details and get validated out of cart context? So that I can calculate the discounted price and render it on the product pages. Is it possible to get the Tea commerce discount coupon details out of Cart context?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 28, 2019 @ 11:36
    Matt Brailsford
    1

    Hi @Vineeth,

    Unfortunately not. The only way I could see it working is if when you go to the product page, you created a temporary Order with just that item in it and dyanmically applied the discount in order to have it run through the calculation process as these things are only ever run on Order.Save(). That might be ok for the individual order pages, but if you need to list them, that would be a huge overhead.

    You might in theory be able to call the DiscountsService.ApplyDiscounts() and OrderCalculator.CalculateOrder but TC runs these in quite a specific order so I think it's best to leave that to TC as part of the Order.Save() method in case this ever changes.

    As I say, if you know the calculation that needs to be performed (ie, if your rule isn't too complex), it might be easier to run the calculation manually.

Please Sign in or register to post replies

Write your reply to:

Draft