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#.
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 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 = ""; }
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
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
wow amazing reply.
I'll have a look.
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 :)
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
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();
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
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..
is working on a reply...