I am trying to create a new shipping calculator, to do this I've tried to follow the documentation (http://documentation.teacommerce.net/net-api/price-calculators/shipping-calculator/). Ive created a new class (CustomShippingCalculator.cs) in App_Code and then just copied the code from the docs. So this is what I got:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TeaCommerce.Api.Dependency;
using TeaCommerce.Api.Models;
using TeaCommerce.Api.PriceCalculators;
using TeaCommerce.Api.Services;
namespace TeaCommerce.API.PriceCalculators /*<--- is this correct?*/ {
[SuppressDependency( "TeaCommerce.Api.PriceCalculators.IShippingCalculator", "TeaCommerce.Api" )]
public class CustomShippingCalculator : ShippingCalculator {
public CustomShippingCalculator( IVatGroupService vatGroupService, ICurrencyService currencyService )
: base( vatGroupService, currencyService ) {
}
protected override decimal CalculatePrice( ShippingMethod shippingMethod, Currency currency, long countryId, long? countryRegionId ) {
//Estimated shipping price - no order is present
return 100M;
}
protected override decimal CalculatePrice( ShippingMethod shippingMethod, Currency currency, Order order ) {
//Calculate price based on order
return 50M;
}
}
}
But the freight cost for orders is still the same they where before I added this.. Why doesnt this work? and what should I do to get it to work?
Create new Shipping Calculator
Hello
I am trying to create a new shipping calculator, to do this I've tried to follow the documentation (http://documentation.teacommerce.net/net-api/price-calculators/shipping-calculator/). Ive created a new class (CustomShippingCalculator.cs) in App_Code and then just copied the code from the docs. So this is what I got:
But the freight cost for orders is still the same they where before I added this.. Why doesnt this work? and what should I do to get it to work?
You should build a dll and add it to the bin folder instead of just having it in the App_Code folder.
Kind regards
Anders
hmm, how do I do that?
Create a Visual Studio class library and then build it and it will output a dll that you can copy to the /bin folder of your website.
Hi Anders,
I have a problem with running CustomShippingCalculator for orders
It's not working in separate dll and in app_code
is working on a reply...