Copied to clipboard

Flag this post as spam?

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

  • Dan 1265 posts 3835 karma points admin c-trib
    Aug 01, 2013 @ 21:44

    Tea Commerce 2 discount code


    What is the recommended approach for adding discount codes to Tea Commerce 2?  I have a requirement to discount the total cart order (excluding shipping) by 10%.  I found a post which asks this exact question ( but the replies link to posts which I'm finding confusing and not particularly related (at least I can't make the connection very easily).

    Any basic pointers would be very much appreciated as I don't know the Tea Commerce 2 internal workings very well at all and still there doesn't seem to be any documentation that explains this kind of thing.

    Thanks for any help - it would be really appreciated.

  • Rune Grønkjær 1310 posts 2904 karma points
    Aug 02, 2013 @ 08:18
    Rune Grønkjær

    Hi Dan,

    You would have to do a new order calculator using the Tea Commerce API. Here's a few lines of code illustrating how to "hook" in and calculate the order line unit prices. As you can see it's a simple override of at method and there are a lot more methods to override in the OrderCalculator class

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

    namespace YourApp.TeaCommerceExtension {

    [SuppressDependency( "TeaCommerce.Api.PriceCalculators.IOrderCalculator", "TeaCommerce.Api" )] public class OrderCalculator : TeaCommerce.Api.PriceCalculators.OrderCalculator {

    public OrderCalculator( IVatGroupService vatGroupService, ICurrencyService currencyService, IShippingMethodService shippingMethodService, IPaymentMethodService paymentMethodService, IShippingCalculator shippingCalculator, IPaymentCalculator paymentCalculator, IProductInformationExtractor productInformationExtractor )
      : base( vatGroupService, currencyService, shippingMethodService, paymentMethodService, shippingCalculator, paymentCalculator, productInformationExtractor ) {
    protected override decimal CalculateOrderLineUnitPrice( OriginalUnitPrice originalUnitPrice, OrderLine orderLine, Currency currency, Order order ) {
      //... Do code here

    } }


  • Rune Grønkjær 1310 posts 2904 karma points
    Aug 02, 2013 @ 08:19
    Rune Grønkjær

    Hmm. The new editor f*ed up the last two curly brackets. remember them as well.


Please Sign in or register to post replies

Write your reply to: