Copied to clipboard

Flag this post as spam?

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


  • Vineeth 33 posts 173 karma points
    1 week ago
    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 2142 posts 10518 karma points MVP 6x c-trib
    1 week ago
    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 33 posts 173 karma points
    1 week ago
    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 2142 posts 10518 karma points MVP 6x c-trib
    1 week ago
    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 33 posts 173 karma points
    1 week ago
    Vineeth
    0

    Ok anyway thanks for the help Matt :) .

  • Matt Brailsford 2142 posts 10518 karma points MVP 6x c-trib
    1 week ago
    Matt Brailsford
    0

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

  • Vineeth 33 posts 173 karma points
    1 week ago
    Vineeth
    0

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

  • Matt Brailsford 2142 posts 10518 karma points MVP 6x c-trib
    1 week ago
    Matt Brailsford
    0

    Ok great, let me know how you get on 👍

  • Vineeth 33 posts 173 karma points
    6 days ago
    Vineeth
    0

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

  • Vineeth 33 posts 173 karma points
    6 days ago
    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 2142 posts 10518 karma points MVP 6x c-trib
    6 days ago
    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 33 posts 173 karma points
    6 days ago
    Vineeth
    0

    Yeah sure

  • Matt Brailsford 2142 posts 10518 karma points MVP 6x c-trib
    6 days ago
    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 33 posts 173 karma points
    1 day ago
    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 2142 posts 10518 karma points MVP 6x c-trib
    1 day ago
    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 33 posts 173 karma points
    1 day ago
    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 2142 posts 10518 karma points MVP 6x c-trib
    1 day ago
    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 33 posts 173 karma points
    1 day ago
    Vineeth
    0

    Thank you Matt

  • Matt Brailsford 2142 posts 10518 karma points MVP 6x c-trib
    1 day ago
    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 33 posts 173 karma points
    1 day ago
    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 2142 posts 10518 karma points MVP 6x c-trib
    1 day ago
    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 33 posts 173 karma points
    1 day ago
    Vineeth
    0

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

  • Matt Brailsford 2142 posts 10518 karma points MVP 6x c-trib
    1 day ago
    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 33 posts 173 karma points
    1 day ago
    Vineeth
    0

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

  • Vineeth 33 posts 173 karma points
    23 hours ago
    Vineeth
    0

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

  • Matt Brailsford 2142 posts 10518 karma points MVP 6x c-trib
    14 hours ago
    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.

Please Sign in or register to post replies

Write your reply to:

Draft