CarrierService API With Custom Method Definitions by Products

Highlighted
New Member
6 0 0

I'm getting the following checkout error when attempting to create a cart

Screen Shot 2020-11-16 at 12(1).png

I checked my API response which looks like:


```

{
"rates": [
{
"service_name": "Expected Delivery by Thursday Nov 19",
"description": "Fulfilled by USPS Priority",
"service_code": "USPS Priority",
"total_price": "0",
"currency": "USD",
"min_delivery_date": "2020-11-19 17:23:03 +0000",
"max_delivery_date": null
},
{
"service_name": "Expected Delivery by Tuesday Nov 17",
"description": "Fulfilled by USPS Priority Mail Express",
"service_code": "USPS Priority Mail Express",
"total_price": "2425",
"currency": "USD",
"min_delivery_date": "2020-11-17 17:23:03 +0000",
"max_delivery_date": null
}
]
}
```

and is returning 201 when I make the API call on my server end.

 

The store has the following store configurations:

Screen Shot 2020-11-16 at 1.47.06 PM.png
Screen Shot 2020-11-16 at 12.png

 

What am I missing?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
179 22 29

Hey @parcelyze 

It's possible your endpoint isn't responding with the shipping rates in a timely fashion, which could be why you are seeing that error. Can you confirm what kind of response time your app is performing in? 

Kevin_A | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
New Member
6 0 0

Hi Kevin,

I verified the delivery profile information is in fact correct for my store (parcelyze.myshopify.com) via installing the graphql explorer:

{
  "data": {
    "deliveryProfiles": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/DeliveryProfile/58928169119",
            "name": "General Profile",
            "default": true,
            "profileLocationGroups": [
              {
                "locationGroup": {
                  "id": "gid://shopify/DeliveryLocationGroup/64814448799",
                  "locations": {
                    "edges": [
                      {
                        "node": {
                          "id": "gid://shopify/Location/47343829151",
                          "name": "650 w north st"
                        }
                      }
                    ]
                  }
                },
                "locationGroupZones": {
                  "edges": [
                    {
                      "node": {
                        "methodDefinitions": {
                          "edges": []
                        }
                      }
                    }
                  ]
                }
              }
            ],
            "profileItems": {
              "edges": []
            }
          }
        },
        {
          "node": {
            "id": "gid://shopify/DeliveryProfile/69723127967",
            "name": "Parcelyze Shipping Rates",
            "default": false,
            "profileLocationGroups": [
              {
                "locationGroup": {
                  "id": "gid://shopify/DeliveryLocationGroup/70658752671",
                  "locations": {
                    "edges": [
                      {
                        "node": {
                          "id": "gid://shopify/Location/47343829151",
                          "name": "650 w north st"
                        }
                      }
                    ]
                  }
                },
                "locationGroupZones": {
                  "edges": [
                    {
                      "node": {
                        "methodDefinitions": {
                          "edges": [
                            {
                              "node": {
                                "id": "gid://shopify/DeliveryMethodDefinition/312520310943",
                                "name": "parcelyze",
                                "active": true,
                                "rateProvider": {
                                  "id": "gid://shopify/DeliveryParticipant/52494303391"
                                }
                              }
                            }
                          ]
                        }
                      }
                    }
                  ]
                }
              }
            ],
            "profileItems": {
              "edges": [
                {
                  "node": {
                    "product": {
                      "id": "gid://shopify/Product/5324268470431",
                      "handle": "t-shirt"
                    },
                    "variants": {
                      "edges": [
                        {
                          "node": {
                            "id": "gid://shopify/ProductVariant/34858036592799",
                            "title": "Default Title"
                          }
                        }
                      ]
                    }
                  }
                },
                {
                  "node": {
                    "product": {
                      "id": "gid://shopify/Product/5552865706143",
                      "handle": "coffee-mug"
                    },
                    "variants": {
                      "edges": [
                        {
                          "node": {
                            "id": "gid://shopify/ProductVariant/35789976699039",
                            "title": "Default Title"
                          }
                        }
                      ]
                    }
                  }
                }
              ]
            }
          }
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 155,
      "actualQueryCost": 40,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 960,
        "restoreRate": 50
      }
    }
  }
}


I also modified the delivery carrier service endpoint it calls to retrieve rates to return literally a static set of rates used in the sample response in the admin API example:

curl -H 'Content-Type: application/json' -X POST https://parcelyze.com/api/shipment/rates/ -d '{"rate": {}}'

{"rates":[{"service_name":"canadapost-overnight","service_code":"ON","total_price":"1295","description":"This is the fastest option by far","currency":"CAD","min_delivery_date":"2013-04-12 14:48:45 -0400","max_delivery_date":"2013-04-12 14:48:45 -0400"},{"service_name":"fedex-2dayground","service_code":"2D","total_price":"2934","currency":"USD","min_delivery_date":"2013-04-12 14:48:45 -0400","max_delivery_date":"2013-04-12 14:48:45 -0400"},{"service_name":"fedex-priorityovernight","service_code":"1D","total_price":"3587","currency":"USD","min_delivery_date":"2013-04-12 14:48:45 -0400","max_delivery_date":"2013-04-12 14:48:45 -0400"}]}

 
This is a pretty instantaneous return. What else could be going wrong? Does the response need to be 200? Am I missing anything else on the response?

0 Likes
Highlighted
New Member
6 0 0

I even see the shopify servers successfully making the requests to receive that data:

 

nginx_1 | 34.73.25.175 - - [18/Nov/2020:04:16:39 +0000] "POST /api/shipment/rates/ HTTP/1.1" 201 642 "-" "Ruby" "-"
nginx_1 | 34.73.25.175 - - [18/Nov/2020:04:16:40 +0000] "POST /api/shipment/rates/ HTTP/1.1" 201 642 "-" "Ruby" "-"
nginx_1 | 34.73.25.175 - - [18/Nov/2020:04:16:40 +0000] "POST /api/shipment/rates/ HTTP/1.1" 201 642 "-" "Ruby" "-"
nginx_1 | 34.73.25.175 - - [18/Nov/2020:04:16:40 +0000] "POST /api/shipment/rates/ HTTP/1.1" 201 642 "-" "Ruby" "-"
nginx_1 | 35.185.4.143 - - [18/Nov/2020:04:17:27 +0000] "POST /api/shipment/rates/ HTTP/1.1" 201 642 "-" "Ruby" "-"
nginx_1 | 34.73.114.255 - - [18/Nov/2020:04:18:44 +0000] "POST /api/shipment/rates/ HTTP/1.1" 201 642 "-" "Ruby" "-"

0 Likes
Highlighted
New Member
6 0 0

@Kevin_A  I managed to do some digging around and I think there is a bug here:

1. If the "General Profile" -- the default profile for the store -- is given the carrier service rate provider and has products defaulted to it, the rates return fine as normal.

2. When the "App Profile" -- the delivery profile generated by the app -- has location zones / variant ids associated to it those location zones & variant ids no longer work, even with the general profile rate provider still configured.

You need at least ONE product/variant in the "General Profile" to make things work. What if my app wants to control all the product shipping potentially or just control half the products?

0 Likes
Highlighted
New Member
6 0 0

@Kevin_AI figured out the solution.. ignore the previous bug comments. It was because when I generated the delivery profile with deliveryProfileCreate, the DeliveryParticipantInput.adaptToNewServices was not set to true. 

Now that I have the delivery profile set to adapt to new services, it isnt recognizing more than one returned result. I even tried adding in DeliveryParticipantInput.participantServices like:

methodDefinitionsToCreate: [
                    {
                      name: "parcelyze"
                      active: true,
                      participant: {
                        # your carrier service id
                        carrierServiceId: "${SHOPIFY_DELIVERY_SERVICE_GID}"
                        adaptToNewServices: true
                        participantServices: [
                           {
                             name: "Service 1",
                             active: true
                           },
                           {
                             name: "Service 2",
                             active: true
                           },
                           {
                             name: "Service 3"
                             active: true
                           }
                        ]
                      }
                    }


My participant services 'service_name's are dynamic so they don't match. Is this a problem? Right now all I get in my cart is the first rate I return in my list of rates and none of the rest.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
179 22 29

Hey @parcelyze 

Thanks for all the info! I'm going to send up an issue to my team to investigate further. 

Kevin_A | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes