Creating a custom shipping calculator in Tea Commerce 3
Hi,
I'm trying to implement a custom shipping method in Tea Commerce 3 on Umbraco 7.1.8 (upgraded from Tea Commerce 2).
I've created a class based on the documentation but am not sure how to register this so Tea Commerce uses it. I've seen this topic but can't find the config for Tea Commerce in the current version
If you want to override the default shipping calculator then you do not have to edit any configuration files. Just use the "SuppressDependency" line from the documentation you found and autofac will handle this for you. With a custom shipping calculator you will be able to override functions which calculate the shipping price and vat rate.
If you need to do something custom for one shipping method but let all other shipping methods calculate as normal. Then I would suggest looking at the supplied shippingMethod, the shippingMethod will have an alias which you can use to differentiate between the shipping methods on the website.
If you need further information/explanation feel free to ask and I will try to answer/elaborate :)
Thank you for your reply Anders. I have already resolved the issue, i have installed the starter pack before installing the base tea commerce package..
Creating a custom shipping calculator in Tea Commerce 3
Hi,
I'm trying to implement a custom shipping method in Tea Commerce 3 on Umbraco 7.1.8 (upgraded from Tea Commerce 2).
I've created a class based on the documentation but am not sure how to register this so Tea Commerce uses it. I've seen this topic but can't find the config for Tea Commerce in the current version
Sorry, I'm new to all this
Thanks,
Geoff
Hi Geoff,
If you want to override the default shipping calculator then you do not have to edit any configuration files. Just use the "SuppressDependency" line from the documentation you found and autofac will handle this for you. With a custom shipping calculator you will be able to override functions which calculate the shipping price and vat rate.
If you need to do something custom for one shipping method but let all other shipping methods calculate as normal. Then I would suggest looking at the supplied shippingMethod, the shippingMethod will have an alias which you can use to differentiate between the shipping methods on the website.
If you need further information/explanation feel free to ask and I will try to answer/elaborate :)
Great, thanks Kim. That clarifys it for me.
Here's my code in case it helps anyone else.
using TeaCommerce.Api.Dependency;
using TeaCommerce.Api.Models;
using TeaCommerce.Api.PriceCalculators;
using TeaCommerce.Api.Services;
namespace TeaCommerce.Tests.PriceCalculators
{
[SuppressDependency("TeaCommerce.Api.PriceCalculators.IShippingCalculator", "TeaCommerce.Api")]
publicclassShippingInXpress : ShippingCalculator
{
public ShippingInXpress(IVatGroupService vatGroupService)
: base(vatGroupService)
{
}
public override Price CalculatePrice(ShippingMethod shippingMethod, Currency currency, Order order)
{
if (shippingMethod.Alias == "inexpress")
{
//TODO: call custom shipping calculator
return new Price(15, 0, 15, currency);
}
else
{
//let the existing price calculator run
return base.CalculatePrice(shippingMethod, currency, order);
}
}
}
}
Here is the documentation: http://documentation.teacommerce.net/net-api/price-calculators/shipping-calculator/
Kind regards
Anders
Hi
I have this error in line @using TeaCommerce.Api.Models
"The type or namespace name 'Api' does not exist in the namespace 'TeaCommerce' (are you missing an assembly reference?)"
can anyone help me?
Thanks
Hi Ruben. Do you have a reference to the right dll files? TeaCommerce.Api.dll
Running v2 or v3 of Tea Commerce?
Kind regards
Anders
Thank you for your reply Anders. I have already resolved the issue, i have installed the starter pack before installing the base tea commerce package..
is working on a reply...