Copied to clipboard

Flag this post as spam?

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


  • Jeavon Leopold 3008 posts 13210 karma points MVP 7x admin c-trib
    May 13, 2013 @ 10:10
    Jeavon Leopold
    0

    Shipping cost multiplied by total quantity

    Hi There,

    Could you please advise me the best/easiest way to multiply the shipping cost (set by country and region) by the total quantity of items in the order using a custom shipping calculator in v2.1?

    Thanks,

    Jeavon

  • Anders Burla Johansen 2560 posts 8256 karma points
    May 13, 2013 @ 10:31
    Anders Burla Johansen
    0

    Hi Jeavon

    See this post about a custom shipping calculator:
    http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/40587-Shipping-per-product

    Kind regards
    Anders

  • Jeavon Leopold 3008 posts 13210 karma points MVP 7x admin c-trib
    May 13, 2013 @ 13:01
    Jeavon Leopold
    0

    Hi Anders,

    It was actually the properties required to calculate the shipping by the total quantity I was looking for, below is what I have currently used (maybe there is a better way?)?

       [SuppressDependencyAttribute( "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, Order order) { long countryId = order.ShipmentInformation.CountryId ?? default(long); long? countryRegionId = order.ShipmentInformation.CountryRegionId; decimal currentShippingPrice = shippingMethod.GetOriginalPrice(currency.Id, countryId, countryRegionId); decimal totalQuantity = order.OrderLines.Sum(x => x.Quantity); return currentShippingPrice * totalQuantity; } }

    Thanks,

    Jeavon

  • Anders Burla Johansen 2560 posts 8256 karma points
    May 13, 2013 @ 13:19
    Anders Burla Johansen
    100

    I would properly use:

    decimal currentShippingPrice = base.CalculatePrice( shippingMethod, currency, order )
    decimal totalQuantity = order.OrderLines.Sum(x => x.Quantity);
    return currentShippingPrice * totalQuantity;

    Thats it :)

    Kind regards
    Anders

  • Jeavon Leopold 3008 posts 13210 karma points MVP 7x admin c-trib
    May 13, 2013 @ 13:35
    Jeavon Leopold
    0

    Awesome! When will the .NET API new documentation be ready?

  • Anders Burla Johansen 2560 posts 8256 karma points
    May 13, 2013 @ 13:40
    Anders Burla Johansen
    0

    Dont have a specific date - we will work on it and release each page about the .NET part when its ready

Please Sign in or register to post replies

Write your reply to:

Draft