Copied to clipboard

Flag this post as spam?

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


  • Robert 30 posts 110 karma points
    Oct 07, 2013 @ 15:45
    Robert
    0

    Promotions/ Discount codes in Tea Commerce

    Hi,

    I'm using Tea Commerce 2.1 and I've got a working store!

    Now my requirement is to add promotion codes. So basically on the shopping cart page the customer enters a promotion code and if it's valid this will say reduce the order by 10%.

    I've got it linked to a Base method and I've validated the code is valid but I can't seem to work out how to reduce the order lines by 10%. (We're integrating into a system where by I need to reduce the order lines by 10% not add a minus order line). So I was hoping to call TC.UpdateOrderLine but can't figure it out, I'm doing it in C#.

    Anyone got any examples?

    Thanks

    Rob

     

  • Anders Burla 2560 posts 8256 karma points
    Oct 07, 2013 @ 15:48
    Anders Burla
    100

    Hi Robert

    When you have validated the promo code then add a order property with the discount of 10%. Now make an order calculator that use this info and give 10% discount.
    http://documentation.teacommerce.net/net-api/price-calculators/order-calculator/

    Kind regards
    Anders

  • Robert 30 posts 110 karma points
    Oct 07, 2013 @ 15:56
    Robert
    0

    wow amazing reply.

    I'll have a look.

  • Anders Burla 2560 posts 8256 karma points
    Oct 07, 2013 @ 15:57
    Anders Burla
    0

    Remember to save the order property using the .NET API and save it as server secure. Then the client side cant change it. I needs to be safe :)

  • Robert 30 posts 110 karma points
    Oct 07, 2013 @ 16:06
    Robert
    0

    Ok cool,

    I've basically copied the example from the link you posted and put a breakpoint on the first line of the CalculateOrderLineUnitPrice and gets hit. It's in the name folder and namespace as my Base handler which does get hit.

    I've booted IIS but it's not done anything.

    Thanks

    Rob

     

  • Robert 30 posts 110 karma points
    Oct 07, 2013 @ 17:06
    Robert
    0

    I've basically got this and it's not making any difference to any totals.

    using TeaCommerce.Api.Dependency;
    using TeaCommerce.Api.InformationExtractors;
    using TeaCommerce.Api.Models;
    using TeaCommerce.Api.PriceCalculators;
    using TeaCommerce.Api.Services;
    using umbraco.NodeFactory;

    namespace MyWebsite.App_Code
    {
        [SuppressDependency("TeaCommerce.Api.PriceCalculators.IOrderCalculator", "TeaCommerce.Api")]
        public class CustomOrderCalculator : OrderCalculator
        {
            public CustomOrderCalculator(IVatGroupService vatGroupService, ICurrencyService currencyService, IShippingMethodService shippingMethodService, IPaymentMethodService paymentMethodService, IShippingCalculator shippingCalculator, IPaymentCalculator paymentCalculator, IProductInformationExtractor productInformationExtractor)
                : base(vatGroupService, currencyService, shippingMethodService, paymentMethodService, shippingCalculator, paymentCalculator, productInformationExtractor)
            {
                string ii = "";
            }

            protected override decimal CalculateOrderLineUnitPrice(OriginalUnitPrice originalUnitPrice, OrderLine orderLine, Currency currency, Order order)
            {
                int promotionNodeId = 0;
                return 2.0;
            }
        }
    }

     

    I've tried saving the order to get it to refresh, anything I'm missing still can't get it to hit a break point.

     var order = TC.GetCurrentOrder(storeId);
     order.Save();

     




  • Anders Burla 2560 posts 8256 karma points
    Oct 08, 2013 @ 00:38
    Anders Burla
    0

    You should not save the order in your code. Did you build a dll and copied it to your /bin folder? App_Code won't work.

    Kind regards
    Anders

  • Robert 30 posts 110 karma points
    Oct 08, 2013 @ 09:28
    Robert
    0

    I've come in this morning and now it's started hitting my breakpoint so I can move forward. Must have been some form of VS cache, not sure..

Please Sign in or register to post replies

Write your reply to:

Draft