Copied to clipboard

Flag this post as spam?

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


  • M N 125 posts 212 karma points
    Jan 08, 2018 @ 18:06
    M N
    0

    Dynamic Shipipng Method Resources Possible?

    Hello,

    I'm creating a shipping provider for easypost.com , and had a high level question. Since all shipping providers seem to require you to add resources (FedEx 2day, FedEx Overnight, etc). I was wondering what the best approach for dynamic Resources. Specifically, EasyPost allows you to connect your UPS, FedEx, DHL, etc and their API abstracts all those shipping methods into a distilled list when you request quotes. So I'll get back maybe 6 quotes from FedEx, 6 quotes from UPS, but it's always different depending on addresses and such.

    I am working backwards from the FedEx shipping provider, and see this code in the GatewayProvider

    public override IEnumerable<IShippingGatewayMethod> GetShippingGatewayMethodsForShipment(IShipment shipment)
        {
            var methods = base.GetShippingGatewayMethodsForShipment(shipment);
    
            var shippingMethods = new List<IShippingGatewayMethod>();
            foreach (var method in methods)
            {     
                var quote = method.QuoteShipment(shipment);
    
                if (quote.Result.Rate > (decimal) 0.00)
                {
                    shippingMethods.Add(method);
                }
            }
    
            return shippingMethods;
        }
    

    But in this situation there is really only one shipping method, with many rates. However, the FedEx plugin each "Quote" is essentially a "Resource" in backoffice, right? Unless I missed something here.

    Any suggestions welcome. Thanks! -Marc

  • M N 125 posts 212 karma points
    Jan 08, 2018 @ 21:22
    M N
    0

    Just a little extra info, I have this sort of working, but naturally since there is only one "Method" on the "Provider", there is only one being added.

    And I'm not sure the best way to even customize the Method return for the SelectList - too much abstraction going on and my head is spinning.

    enter image description here

    Here is a full response from EasyPost API Rate Quote (you'll see UPS / Fedex as I have those linked in EasyPost) - Hence my question is it possible to have dynamic methods on a provider? Or is there any way to hack around it? enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft