Copied to clipboard

Flag this post as spam?

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


  • Pete Naylor 21 posts 39 karma points
    Apr 03, 2012 @ 13:56
    Pete Naylor
    0

    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?

  • Anders Burla 2560 posts 8256 karma points
    Apr 03, 2012 @ 15:35
    Anders Burla
    0

    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

  • Pete Naylor 21 posts 39 karma points
    Apr 03, 2012 @ 16:21
    Pete Naylor
    0

    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? 

  • Anders Burla 2560 posts 8256 karma points
    Apr 04, 2012 @ 08:33
    Anders Burla
    0

    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

  • Pete Naylor 21 posts 39 karma points
    Apr 04, 2012 @ 15:34
    Pete Naylor
    0

    Thanks Anders.

    I've got it working now.  

  • Anders Burla 2560 posts 8256 karma points
    Apr 04, 2012 @ 15:36
    Anders Burla
    0

    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

  • Hutch White 89 posts 112 karma points
    Dec 03, 2012 @ 19:29
    Hutch White
    0

    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!

  • Anders Burla 2560 posts 8256 karma points
    Dec 04, 2012 @ 08:24
    Anders Burla
    0

    I know that Rasmus is also doing some discount stuff at the moment - http://www.rasmusfjord.dk/

    Kind regards
    Anders

  • Pete Naylor 21 posts 39 karma points
    Dec 05, 2012 @ 10:28
    Pete Naylor
    0

    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

     

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft