Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
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?
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?
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.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted