'Can't get min_delivery_date and max_delivery_date when using CarrierService

in Shopify

Dawn theme,

I want to display the minimum and maximum delivery date on page checkout.liquid, using CarrierService (Shopify API).

I need to get min_delivery_date and max_delivery_date. And the problem is that I make a request for - /admin/api/2022-01/carrier_services.json, and I get a response that doesn't have min_delivery_date and max_delivery_date.

I get this response:

{
   "carrier_services":[
      {
         "id":57492111453,
         "name":"dhl_express",
         "active":true,
         "service_discovery":true,
         "carrier_service_type":"legacy"
      },
      {
         "id":57492144221,
         "name":"ups_shipping",
         "active":true,
         "service_discovery":true,
         "carrier_service_type":"legacy"
      },
      {
         "id":57492078685,
         "name":"usps",
         "active":true,
         "service_discovery":true,
         "carrier_service_type":"legacy"
      }
   ]
}

Question: Why are the values min_delivery_date and max_delivery_date not displayed?

I can't understand why this is happening.

Please help.



Solution 1:[1]

You are asking Shopify to give you a list of carrier services, and it is responding correctly. You are seeing three, DHL, UPS and USPS. Asking Shopify for a list of carrier services has nothing to do with checkout, and a request made to a Carrier Service.

If you wanted to know the delivery dates of a shipping rate response, you'd have to be inspecting the response from the carrier services! And that is not something you get to do. Instead, you get to form the responses themselves when you deploy your carrier services in your own App.

So clearly, if you are interested in min/max delivery dates, open up the code in the App you installed, and discover why no dates are being provided. Also, note that playing with the min/max delivery dates in response is tricky stuff! It requires a deep understanding of business days, weekends, and the results you respond with to get it right.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1