Copied to clipboard

Flag this post as spam?

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


  • Geoff 19 posts 134 karma points
    Jan 29, 2015 @ 09:01
    Geoff
    0

    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

  • Kim Pilgaard 10 posts 96 karma points
    Jan 30, 2015 @ 12:42
    Kim Pilgaard
    100

    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 :)

  • Geoff 19 posts 134 karma points
    Feb 02, 2015 @ 04:29
    Geoff
    0

    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);

                }

            }

        }

     

    }

  • Anders Burla 2560 posts 8256 karma points
    Feb 02, 2015 @ 14:10
  • Ruben 2 posts 22 karma points
    Apr 21, 2015 @ 10:02
    Ruben
    0

    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

  • Anders Burla 2560 posts 8256 karma points
    Apr 22, 2015 @ 08:26
    Anders Burla
    0

    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

  • Ruben 2 posts 22 karma points
    Apr 27, 2015 @ 09:52
    Ruben
    0

    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.. 

Please Sign in or register to post replies

Write your reply to:

Draft