Copied to clipboard

Flag this post as spam?

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


  • Amar Resic 5 posts 96 karma points
    Oct 30, 2020 @ 14:13
    Amar Resic
    0

    Shipping calculator - using external api returning shipping options

    Hi there.

    I have a case where I need to query a 3rd party api for shipping methods and costs. Based on the shipping address of an order (zip code) and calculated total dimensions of order products (parcel size). Passing these 2 properties to the 3rd party API, it returns applicable shipping methods for an order.

    I can see how I can create a custom ShippingCalculator, and calculate the cost of shipping methods created in Vendr, but I cant quite see if its possible for me to control which shipping methods are displayed for an order, based on the results from the 3rd party API.

    The only potential route I can see thus far, is that I create the avaialble shipping methods in Vendr, and in my calculator I go through each one idividually and query the API to see if it returns a result for this shipping method. However, if it does not, then I need to be able to remove it as an option for this order. Is there a way for me to do that?

    With this approach, I would need to make multiple queries to the 3rd party API. And I would prefer an approach where I can query this only once per order, and only return the shipping methods that are applicable.

    Any way to achieve this with Vendr, would greatly appriciate if anyone can point me in the right direction.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Nov 09, 2020 @ 15:08
    Matt Brailsford
    100

    Hi Amar,

    Apologies for the late reply. I seemed to have messed up my Our notifications 🤦‍♂️

    The ShippingCalculator is generally intended to be used to calculate the cost of shipping at any given time, not to control the display of shipping methods.

    Generally controlling which shipping methods you wish to display would need to occur during your checkout process when you display the options for the user to choose from.

    It sounds like your API is more providing info on whether a shipping method is available, rather than the cost, so really I think this should occur as custom code within your checkout flow prior to rendering your shipping methods. Based on the result back from your API, you can filter the list of payment methods available, and then render that filtered list.

    Hope this helps

    Matt

  • Amar Resic 5 posts 96 karma points
    Nov 10, 2020 @ 13:51
    Amar Resic
    1

    Hey Matt.

    No worries, thanks for the reply.

    That makes sense, and we will account for that in the checkout flow itsself, before using the ShippingCalculator to set the price of shipping.

Please Sign in or register to post replies

Write your reply to:

Draft