I've altered TeaCommerce to accept and store a discount code from the user during the checkout process. I've also created various discounts in the Umbraco back end using document types.
I now need to compare the discount code to those in the list and alter the order accordingly. While this is easy enough, I'm not sure where I should attempt to apply the discount.
I would like to be able to do this just before Step 4 where the user accepts their order, since I have collected the discount code in step 2,
Can anyone suggest a good place where I can carry out my calculations, preferrably with the discount showing up in the order summary?
If you want to do discounts you will have to use the Tea Commerce .NET API - have you used that before?
When you want your discount to show up in your cart - what I would do is to have a discount product in your node structure with a price of 0. Then when you have added the discount ( if the user show have discount ) - you use the API to calc the price for the discount and have orderLine.UnitPrice = -100; Then its all about presenting this "product" in a special way in the cart flow.
I trying to work out which event to hook onto, I am using BeforePaymentFormGenerated, but this is called after the "accept" page is rendered and so the discount doesn't show until I refresh the page.
Also is it possible to change the text of the line I am adding? I would like to change "Discount" to "Discount 20%" or which whatever the discount is called. Since I cannot change the node name each time, is it possible to add a property to the orderline which I can then read in the XSLT instead of the node name?
When you add the coupon code or discount code - do you add it as an order property? If yes - you could hook into the orderPropertiesUpdated event and look for the alias of the property updated and add the discount. You can just overwrite the properties copied to the orderline. Just update it and it should overwrite the value.
I'm looking to do this exact thing in a Tea Commerce instance I have. If you have any pointers, code, advice or notes that would greatly be appreciated!
I don't have access to my code anymore, but from what I can remember:
I created a document type and section in Umbraco called discounts. The document type had a start date, an end date, a discount code, an amount and a drop down for either percentage or value (e.g. $20 or 20% off)
I wrote an extension and hooked it into the "OrderPropertiesUpdated" event
This looked up the parent node of the discounts and checked each discount against an extra field I had added to the checkout form.
If the code matches, it checks if the code is in date and that the discount hasn't already been applied and then applies the discount.
I think I may have also added further text to the checkout process to show the discount is applied
Which API hook to apply discount.
I've altered TeaCommerce to accept and store a discount code from the user during the checkout process. I've also created various discounts in the Umbraco back end using document types.
I now need to compare the discount code to those in the list and alter the order accordingly. While this is easy enough, I'm not sure where I should attempt to apply the discount.
I would like to be able to do this just before Step 4 where the user accepts their order, since I have collected the discount code in step 2,
Can anyone suggest a good place where I can carry out my calculations, preferrably with the discount showing up in the order summary?
Hi Pete
If you want to do discounts you will have to use the Tea Commerce .NET API - have you used that before?
When you want your discount to show up in your cart - what I would do is to have a discount product in your node structure with a price of 0. Then when you have added the discount ( if the user show have discount ) - you use the API to calc the price for the discount and have orderLine.UnitPrice = -100; Then its all about presenting this "product" in a special way in the cart flow.
Makes sense? :)
Kind regards
Anders
Hi Anders.
Thanks for your reply. I am using the .NET API.
I trying to work out which event to hook onto, I am using BeforePaymentFormGenerated, but this is called after the "accept" page is rendered and so the discount doesn't show until I refresh the page.
Also is it possible to change the text of the line I am adding? I would like to change "Discount" to "Discount 20%" or which whatever the discount is called. Since I cannot change the node name each time, is it possible to add a property to the orderline which I can then read in the XSLT instead of the node name?
Hi Pete
When you add the coupon code or discount code - do you add it as an order property? If yes - you could hook into the orderPropertiesUpdated event and look for the alias of the property updated and add the discount. You can just overwrite the properties copied to the orderline. Just update it and it should overwrite the value.
Kind regards
Anders
Thanks Anders.
I've got it working now.
Great. If you found my answer helpful could you please mark it as the solution so others easily can find the solution :)
Kind regards
Anders
Hi Pete,
I'm looking to do this exact thing in a Tea Commerce instance I have. If you have any pointers, code, advice or notes that would greatly be appreciated!
Thanks!
I know that Rasmus is also doing some discount stuff at the moment - http://www.rasmusfjord.dk/
Kind regards
Anders
I don't have access to my code anymore, but from what I can remember:
I created a document type and section in Umbraco called discounts. The document type had a start date, an end date, a discount code, an amount and a drop down for either percentage or value (e.g. $20 or 20% off)
I wrote an extension and hooked it into the "OrderPropertiesUpdated" event
This looked up the parent node of the discounts and checked each discount against an extra field I had added to the checkout form.
If the code matches, it checks if the code is in date and that the discount hasn't already been applied and then applies the discount.
I think I may have also added further text to the checkout process to show the discount is applied
is working on a reply...