Copied to clipboard

Flag this post as spam?

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


  • Matt Taylor 873 posts 2086 karma points
    Jul 11, 2014 @ 13:00
    Matt Taylor
    0

    Editing a finalised order in the Tea Commerce UI does not fire the Custom Shipping Calculator

    I've created a custom shipping calculator by overriding:

    protected override decimal CalculatePrice(ShippingMethod shippingMethod, Currency currency, Order order)

    I've not bothered to override the method for when there's no order.

    I'm using to price up the shipping based on the total weight of the cart, it works well.

    Here's an order for one items, you can see the calculated weight and shipping cost.

    Here's an order for three items, you can see the increase in weight and shipping cost.

    Look what happens though when I edit the first order and increase the quantity from 1 to 3 and save it.

    You can see all the totals get updated but the weight and shipping cost does not get recalculated.

    The Shipping Calculator does not get fired.

    Regards,

    Matt

     

  • Anders Burla 2560 posts 8256 karma points
    Jul 11, 2014 @ 13:27
    Anders Burla
    0

    Hi Matt

    In the current version of Tea Commerce the shipping and payment calculators doesnt not recalculate on a finalized order. We have changed that in the version that runs the Marketing module for Tea Commerce. But there is some time until we release this. I think you can override the order calculator and then call every method of the base order calculator.

    Kind regards
    Anders

  • Matt Taylor 873 posts 2086 karma points
    Jul 11, 2014 @ 14:27
    Matt Taylor
    0

    You mean like this?

    [SuppressDependency( "TeaCommerce.Api.PriceCalculators.IOrderCalculator", "TeaCommerce.Api" )]
      public class TeaCommerceOrderCalculator : OrderCalculator
      {
        public TeaCommerceOrderCalculator( IVatGroupService vatGroupService, ICurrencyService currencyService, IShippingMethodService shippingMethodService, IPaymentMethodService paymentMethodService, IShippingCalculator shippingCalculator, IPaymentCalculator paymentCalculator, IProductInformationExtractor productInformationExtractor )
            : base( vatGroupService, currencyService, shippingMethodService, paymentMethodService, shippingCalculator, paymentCalculator, productInformationExtractor )
        {
        }

        public override void CalculateOrder(Order order)
        {
            base.CalculateOrder(order);

            // Add some code here to work out the correct shipping fee.
        }
      }

    Cheers, Matt

     

  • Matt Taylor 873 posts 2086 karma points
    Jul 24, 2014 @ 10:49
    Matt Taylor
    0

    What do you mean here because the OrderCalculator does not seem to get fired either?

  • Anders Burla 2560 posts 8256 karma points
    Jul 28, 2014 @ 09:21
    Anders Burla
    0

    Could you check if it runs at all. Just to check that it has registered the custom calculator.

    Kind regards
    Anders

  • Matt Taylor 873 posts 2086 karma points
    Jul 29, 2014 @ 10:22
    Matt Taylor
    0

    Hi Anders,

    My mistake, the order calculator is being called when an order is updated in the back-end.

    Can you elaborate on what I need to do here to incorporate my shipping calculator code because I'm a bit confused?
    What I should override and where I should insert my logic.

    Regards, Matt

  • Anders Burla 2560 posts 8256 karma points
    Jul 29, 2014 @ 10:36
    Anders Burla
    100

    You should call these methodsn your calculate order method. Now everything will be recalculated at all times. You might want to not calculate the vat rate when the order is finalized. But you decide :)


     CalculateVatRate( order );
    CalculateOrderLines( order );
    CalculateSubtotals( order );
    CalculateShippingCosts( order );
    CalculatePaymentCosts( order );
    CalculateTransactionCosts( order );
    CalculateTotals( order );

    Kind regards
    Anders

  • Matt Taylor 873 posts 2086 karma points
    Jul 29, 2014 @ 12:02
    Matt Taylor
    0

    Thanks Anders,

    Nice and simple and working.

    Cheers, Matt

Please Sign in or register to post replies

Write your reply to:

Draft