Copied to clipboard

Flag this post as spam?

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


  • Johannes Lantz 156 posts 838 karma points c-trib
    May 18, 2022 @ 12:04
    Johannes Lantz
    0

    ShippingCalculator not running

    Hi!

    I recently upgraded from 1.8.6 to 2.2.0 (Umbraco 8.18.3). I had a custom shippingCalculator that worked fine in 1.8.6. But after the upgrade it's not running at all. I got a breakpoint at the start of the method which is not being hit.

    My implementation looks like this:

        public DynamicShippingCalculator(ITaxService taxService, IStoreService storeService) 
            : base(taxService, storeService)
        {
    
        }
    
        public override Price CalculateShippingMethodPrice(ShippingMethodReadOnly shippingMethod, Guid currencyId, Guid? countryId, Guid? regionId, TaxRate taxRate, ShippingCalculatorContext context)
        {
            return base.CalculateShippingMethodPrice(shippingMethod, currencyId, countryId, regionId, taxRate, context);
        }
    
        public override TaxRate CalculateShippingMethodTaxRate(ShippingMethodReadOnly shippingMethod, TaxSource taxSource, TaxRate fallbackTaxRate, ShippingCalculatorContext context)
        {
            return base.CalculateShippingMethodTaxRate(shippingMethod, taxSource, fallbackTaxRate, context);
        }
    }
    

    And composer looks like this:

    [ComposeAfter(typeof(VendrComposer))]
    public class VendrComposerr : IUserComposer
    {
        public void Compose(Composition composition)
        {
    
            composition.RegisterUnique<IShippingCalculator, DynamicShippingCalculator>();
        }
    }
    

    I am really confused why this isn't working.

    Any ideas?

    //Johannes

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    May 18, 2022 @ 12:16
    Matt Brailsford
    0

    Hey Johannes,

    What interactions are you performing on the order as the calculator will only run if it needs to so have you tried swapping the shipping method etc to force it to run?

  • Johannes Lantz 156 posts 838 karma points c-trib
    May 18, 2022 @ 12:50
    Johannes Lantz
    0

    Hi Matt!

    I am using:

                var order = _sessionManager.GetOrCreateCurrentOrder(store.Id)
                                            .AsWritable(uow).SetShippingMethod(shippingMethod);
    

    To set the shipping method. I tried swicthing between 2 shipping methods. I can see how the order changes shippingMethodId changes between the 2. But it's still not reaching CalculateShippingMethodPrice.

    //Johannes

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    May 18, 2022 @ 12:54
    Matt Brailsford
    100

    Hmm, is it because you have called your composer VendrComposer and also set it to compose after VendrComposer and so it's not actually running after our composer, rather it's attempting to compose after itself. Maybe rename your composer and see if that works.

    EDIT: This would explain why it used to work as there used to be a VendrCoreComposer and VendrWebComposer but now there is only one VendrComposer so this might be the conflict.

  • Johannes Lantz 156 posts 838 karma points c-trib
    May 18, 2022 @ 13:08
    Johannes Lantz
    1

    Thank you so much Matt!

    That did it!

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    May 18, 2022 @ 13:09
    Matt Brailsford
    0

    Fantastic 👍

Please Sign in or register to post replies

Write your reply to:

Draft