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 (http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/40867-Percentage-discount) 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.
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
}
Tea Commerce 2 discount code
Hi,
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 (http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/40867-Percentage-discount) 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.
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 {
} }
/Rune
Hmm. The new editor f*ed up the last two curly brackets. remember them as well.
/Rune
is working on a reply...