Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

CarrierService API: Handling Mixed Shipping Profiles

CarrierService API: Handling Mixed Shipping Profiles

Jonathan_ezApps
Shopify Partner
25 0 6

I'm encountering an issue with my CarrierService app, which provides Canada Post & FedEx rates and transit times. I'm using both General and Custom shipping rates in Shopify's Shipping & Delivery settings. Here’s the challenge I’m facing:

 

Scenario with General Shipping Rates Only: When my cart contains only products from the General shipping rates, Shopify sends a single request to my server with an array of items:

 

"items": [
    {
    "name": "product-title",
    "sku": "[-037]", <--- General shipping profile
    "quantity": 1,
    "grams": 16914,
    "price": 74800,
    "vendor": "",
    "requires_shipping": true,
    "taxable": true,
    "fulfillment_service": "manual",
    "properties": {},
    "product_id": 81688840068,
    "variant_id": 47479549092
    },
    {
    "name": "product-title",
    "sku": "[-104]", <--- General shipping profile
    "quantity": 1,
    "grams": 454,
    "price": 9900,
    "vendor": "",
    "requires_shipping": true,
    "taxable": true,
    "fulfillment_service": "manual",
    "properties": {},
    "product_id": 8168781220,
    "variant_id": 4469306484
    }
]


Scenario with Custom Shipping Profiles: However, when the cart contains items from different shipping profiles (General and Custom), Shopify appears to send two separate requests in rapid succession:

    16:13:11 │ remix │     "items": [
    16:13:11 │ remix │       {
    16:13:11 │ remix │         "name": "",
    16:13:11 │ remix │         "sku": "[-104]", <--- General shipping profile
    16:13:11 │ remix │         "quantity": 1,
    16:13:11 │ remix │         "grams": 454,
    16:13:11 │ remix │         "price": 9900,
    16:13:11 │ remix │         "vendor": "vendor",
    16:13:11 │ remix │         "requires_shipping": true,
    16:13:11 │ remix │         "taxable": true,
    16:13:11 │ remix │         "fulfillment_service": "manual",
    16:13:11 │ remix │         "properties": {},
    16:13:11 │ remix │         "product_id": 81687427220,
    16:13:11 │ remix │         "variant_id": 446935936484
    16:13:11 │ remix │       }
    16:13:11 │ remix │     ],

    16:13:14 │ remix │     "items": [
    16:13:14 │ remix │       {
    16:13:14 │ remix │         "name": "product-title",
    16:13:14 │ remix │         "sku": "[-021]",   <--- Custom shipping profile
    16:13:14 │ remix │         "quantity": 1,
    16:13:14 │ remix │         "grams": 41730,
    16:13:14 │ remix │         "price": 99900,
    16:13:14 │ remix │         "vendor": "vendor",
    16:13:14 │ remix │         "requires_shipping": true,
    16:13:14 │ remix │         "taxable": true,
    16:13:14 │ remix │         "fulfillment_service": "manual",
    16:13:14 │ remix │         "properties": {},
    16:13:14 │ remix │         "product_id": 81687751524,
    16:13:14 │ remix │         "variant_id": 446936986852
    16:13:14 │ remix │       }
    16:13:14 │ remix │     ],

Issue:

  • Sku -104 is under a general shipping profile, offering both Canada Post and FedEx rates (with our app setting the Canada Post rate as free and adding an upcharge for FedEx Ground).
  • Sku -021 is under a custom shipping profile, exclusively offering FedEx Ground (set as free in our app).

In theory, when both are purchased together, FedEx Ground should be the only displayed option and be free. However, in practice, we see the FedEx Ground option but with the upcharge amount from Sku 50-4-104 (as it was calculated separately from the first request).

I created a second custom shipping profile to test this issue. Now, with three items in the cart each from different profiles I got 3 requests with the line items being sent as if it each represented a single order.

 

The CarrierService documentation does not clearly address this scenario, making diagnosis challenging.

Question: Should I avoid using custom shipping profiles with a CarrierService app and manage all logic server-side? Utilizing Shopify shipping profiles has significantly reduced the complexity of our server logic and improved response times to under 2 seconds.

Any insights or guidance would be greatly appreciated.

Print and save invoices directly from your order page: https://apps.shopify.com/ezinvoices
Reply 1 (1)

Jonathan_ezApps
Shopify Partner
25 0 6

I sat on this more, and decided to rewrite my code. I simply re-created the shipping profiles inside the app as arrays of products to loop over instead of relying on the Shopify Shipping & Delivery settings (General & Custom shipping profiles).

This way I know that I am getting all the data in the signal request. In any case, it would be great to know that this behavior existed (or perhaps this isn't intentional).

 

I do miss that we could shipping alter our shipping settings directly through Shopify, and am not looking forward to having to create an app interface now. For the time being, I have values hardcoded.

 

Looking forward to seeing what happens

Print and save invoices directly from your order page: https://apps.shopify.com/ezinvoices