Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Mar 20, 2013 @ 14:23
    Dan
    0

    Create shipping provider for Tea Commerce 2

    Hi,

    Does anyone have any idea how to create a shipping provider for Tea Commerce 2?  A broad question I know, but any pointers as to where to start would be very much appreciated.

    Thanks

  • Anders Burla 2560 posts 8256 karma points
    Mar 20, 2013 @ 17:16
    Anders Burla
    0

    Hi Dan

    The place to start is the shipping calculator. This is the one that gives the shipping price to Tea Commerce. Inherit from TeaCommerce.Api.PriceCalculators.ShippingCalculator. Here is one method you need to override (two if you need to supported estimated shipping costs before an order is even created). Override the CalculatePrice method and return the price you need.

    To register your new shipping calculator and let Tea Commerce use it you need to build your dll file and add it to your bin folder. Then go to /umbraco/plugins/tea-commerce/config/configuration.config and add you calculator and register it as TeaCommerce.Api.PriceCalculators.IShippingCalculator. Restart the app pool and Tea Commerce will now use your provider for calculating shipping prices for new orders.

    If you need to make som UI stuff other than the pricing - then this is not Tea Commerce but is just a question of how you can to implement it in the UI in your webshop.

    Kind regards
    Anders

  • Dan 1288 posts 3921 karma points c-trib
    Mar 20, 2013 @ 23:47
    Dan
    0

    Thanks Anders,

    For now I have this (using a hard-coded shipping value of '99.99' just to test with):

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using TeaCommerce.Api;
    
    namespace testShippingProvider
    {
        public class upsShippingProvider : TeaCommerce.Api.PriceCalculators.ShippingCalculator
        {
            protected override decimal CalculatePrice(TeaCommerce.Api.Models.ShippingMethod shippingMethod, TeaCommerce.Api.Models.Currency currency, TeaCommerce.Api.Models.Order order)
            {
                return 99.99M;
            }
        }
    }
    

    However, it's erroring: 'TeaCommerce.Api.PriceCalculators.ShippingCalculator' does not contain a constructor that takes 0 arguments.  Do you know where I'm going wrong?

  • Anders Burla 2560 posts 8256 karma points
    Mar 21, 2013 @ 08:23
    Anders Burla
    0

    Yeah - the shipping provider need these services to work. AutoFac will parse them in. So make a constructor like this:

    public upsShippingProvider ( IVatGroupService vatGroupService, ICurrencyService currencyService ) : base(vatGroupService, currencyService ) {

        }

    That should be it.

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft