Copied to clipboard

Flag this post as spam?

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


  • Vineeth 48 posts 228 karma points
    Jun 11, 2019 @ 05:15
    Vineeth
    0

    Custom Shipping calculator load issue

    I've got an issue on the CustomShippingCalculator when it trying to run on the development environment of Umbraco cloud the code doesn't get hit or getting inside the shipping calculator function. Bt its working fine on my local solution. Any idea. Why this is happening?

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 11, 2019 @ 08:47
    Matt Brailsford
    0

    Hi Vineeth,

    Hmm, that does sound odd. First thing would be to check to make sure your code is absolutely deployed on cloud? And also maybe check your log file to see if there is anything in there to suggest why it wouldn't load?

  • Vineeth 48 posts 228 karma points
    Jun 11, 2019 @ 09:04
    Vineeth
    0

    Tried logging there is no such logs for why it wouldn't load. I've logged inside the customShippingcalculator but that also wouldn't load in the trace logs. Deployed the DLL's manually and deployed again . But no changes.

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 11, 2019 @ 09:07
    Matt Brailsford
    0

    Ok, I'm not too familiar with cloud, but are you able to restart the app instance? Wondering if the DLLs haven't reloaded.

  • Vineeth 48 posts 228 karma points
    Jun 11, 2019 @ 09:47
    Vineeth
    0

    Ok anyway thanks for the help Matt :) .

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 11, 2019 @ 10:30
    Matt Brailsford
    0

    Did you get it to work? Happy to keep suggesting what I can.

  • Vineeth 48 posts 228 karma points
    Jun 11, 2019 @ 11:03
    Vineeth
    0

    Not yet. I'm going to ask the Umbraco cloud support team and let you know

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 11, 2019 @ 12:01
    Matt Brailsford
    0

    Ok great, let me know how you get on 👍

  • Vineeth 48 posts 228 karma points
    Jun 13, 2019 @ 12:36
    Vineeth
    0

    Hi Matt, This issue still persists Cloud support team is also struggling for a solution :( .

  • Vineeth 48 posts 228 karma points
    Jun 13, 2019 @ 12:38
    Vineeth
    0

    Can you please explain how these events work briefly? Is Shipping calculator triggers outside from the domain? Any authentication issue or anything like that to block the event?

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 13, 2019 @ 13:49
    Matt Brailsford
    0

    Hi Vineeth,

    I'm currently away on holiday right now so don't have the source code to hand to dig into this. Are you able to wait till Monday when I'm back?

  • Vineeth 48 posts 228 karma points
    Jun 13, 2019 @ 13:56
    Vineeth
    0

    Yeah sure

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 13, 2019 @ 14:14
    Matt Brailsford
    0

    Awesome. I'll get back to you then. In the meantime enjoy the rest of your week, and thank you for using Tea Commerce.

  • Vineeth 48 posts 228 karma points
    Jun 17, 2019 @ 06:54
    Vineeth
    0

    Hi Matt, I've tried other custom calculators like Order Line Calculator Its works fine on Umbraco cloud development environment. Event triggers finely. Only this issue on the Shipping calculator. :/

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 17, 2019 @ 09:23
    Matt Brailsford
    0

    Hi Vineeth,

    That's very strange as the different calculators are all loaded by the same approach so if one works, I would expect them all to work. Are you doing anything custom with AutoFac at all? this is the DI framework TC uses to load it's dependencies so just making sure there is nothing that would affect it.

  • Vineeth 48 posts 228 karma points
    Jun 17, 2019 @ 09:59
    Vineeth
    0

    Yeah, it's really strange. I'm doing absolutely nothing with AutoFac .Cloud Team is checking since last week they don't have any clue yet .

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 17, 2019 @ 10:12
    Matt Brailsford
    0

    Strange.

    I'm just checking back with the previous project owner just in case they have any known issues or ideas so I'll see what they come back with and let you know.

  • Vineeth 48 posts 228 karma points
    Jun 17, 2019 @ 11:08
    Vineeth
    0

    Thank you Matt

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 17, 2019 @ 12:40
    Matt Brailsford
    0

    Are you able to share the code for you Shipping Calculator? You can strip out the actual logic of the functions if it's sensitive, the main thing I want to see is how you are using the SupressDependency attribute.

  • Vineeth 48 posts 228 karma points
    Jun 17, 2019 @ 12:44
    Vineeth
    0

    Yes sure. Please have a look

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using TeaCommerce.Api.Dependency;
    using TeaCommerce.Api.Models;
    using TeaCommerce.Api.PriceCalculators;
    using TeaCommerce.Api.Services;
    using Umbraco.Core.Logging;
    
    [SuppressDependency("TeaCommerce.Api.PriceCalculators.IShippingCalculator", "TeaCommerce.Api")]
    public class CustomShippingCalculator : ShippingCalculator
    {
    
        public CustomShippingCalculator(IVatGroupService vatGroupService)
          : base(vatGroupService)
        {
    
        }
    
        public override Price CalculatePrice(ShippingMethod shippingMethod, Currency currency, Order order)
        {
            try
            {
                LogHelper.Info<CustomShippingCalculator>($"CustomShippingCalculator/CalculatePrice order id:{order.Id}");
                if (order != null && order.OrderLines.Count() != 0 && !string.IsNullOrWhiteSpace(order.Properties["shippingRateFinal"]))
                {
                    //shippingRate Comes with incl/excl according to VAT logic 
                    var shippingRate = Convert.ToDecimal(order.Properties["shippingRateFinal"]);
    
                    if (shippingRate != 0)
                    {
                        LogHelper.Info<CustomShippingCalculator>($"CustomShippingCalculator/CalculatePrice shippingRate:{shippingRate}");
                        return new Price(shippingRate, new VatRate(0), currency);
                    }
                    else
                    {
                        return new Price(currency);
                    }
                }
                else
                {
                    return new Price(currency);
                }
    
            }
            catch (Exception ex)
            {
                LogHelper.Error<CustomShippingCalculator>($"CustomShippingCalculator/CalculatePrice Error occured due to:", ex);
                throw;
            }
        }
    }
    }
    
  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 17, 2019 @ 12:57
    Matt Brailsford
    0

    Hmm, that looks ok to me.

    Have you looked in your umbraco deploy log files? In Umbraco Cloud dashboard, navigate to Kudu from the project dropdown

    enter image description here

    From there, go to "Debug Console > CMD" from the upper menu, and then in the table below go to "site > deployments" and review the recent deployments log files to see if anything failed to deploy. I have had it before where it's failed to compile on Cloud and so the file deployment has failed (thought I would have expected cloud support to have looked into this for you)

  • Vineeth 48 posts 228 karma points
    Jun 17, 2019 @ 13:11
    Vineeth
    0

    I can't see any deployment error on the logs :/

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 17, 2019 @ 13:16
    Matt Brailsford
    0

    And if you go into "site > wwroot > bin" and download your DLL, are you able to use a tool like DotPeek to review the DLL code and see that your code is in the deployed DLL?

  • Vineeth 48 posts 228 karma points
    Jun 17, 2019 @ 13:21
    Vineeth
    0

    Yeah I will give a try on that and get back to you

  • Vineeth 48 posts 228 karma points
    Jun 18, 2019 @ 04:11
    Vineeth
    0

    I've checked the deployed DLL with DotPeek. All the codes are there.

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 18, 2019 @ 13:18
    Matt Brailsford
    0

    Hmm, I'm really struggling for what else to suggest then.

    If the code is there, and other calculators are working, I can't see why this one wouldn't work.

    Ultimately something must be affecting Autofac in some way, either causing the core module registrations to run multiple times such that it's resetting the overrides, or the class just isn't being found in the DLL. I take it your other calculators are within the same DLL? if so, that would suggest the DLL is being found ok.

    Looking in the code for TC, when supressing a dependency, it should write to the log file if it fails, so again, I would expect to see that if this was the problem.

  • Vineeth 48 posts 228 karma points
    Jun 19, 2019 @ 13:03
    Vineeth
    0

    Yeah It all within the same dll. We've tried a basic Umbraco website with teacommerce starter kit installed and done a hardcoded shipping calculator that given in the teacommerce doc . The website was hosted out of umbraco cloud and it worked.

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 19, 2019 @ 13:25
    Matt Brailsford
    100

    Wow, that's pretty strange.

    Ok, last thing I can think. Just before the shipping calculator is called, it checks order.ShipmentInformation.ShippingMethodId and if it's null, it won't access the calculator.

    Your order has a shipping method id set right?

  • Vineeth 48 posts 228 karma points
    Jun 19, 2019 @ 13:22
    Vineeth
    0

    I didn't get what you said on resetting the overrides issue

    ' causing the core module registrations to run multiple times such that it's resetting the overrides' ?

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 19, 2019 @ 13:27
    Matt Brailsford
    1

    Just if Autofac is configured twice, you might get a situation like

    • Configure Autofac defaults
    • Apply SuppressDependency overrides
    • Second configure Autofac defaults triggered removing previous overrides
  • Vineeth 48 posts 228 karma points
    Jun 19, 2019 @ 13:48
    Vineeth
    0

    Oh, my man. That was a shipping id setting issue. It worked now :D . Thanks a lot. :D

  • Matt Brailsford 2279 posts 11088 karma points MVP 6x c-trib
    Jun 19, 2019 @ 14:16
    Matt Brailsford
    2

    🎉🎉🎉🎉🎉

    Phew! Well that took some doing, but so glad we got there.

Please Sign in or register to post replies

Write your reply to:

Draft