CarrierService and adding additional shipping information

Highlighted
New Member
5 0 0

I'm looking for some advice on how to send additional data from user-controlled inputs in the checkout flow to the Carrier Service. We're using an external application to get shipping options and rates for a Shopify Plus store, using the CarrierService API endpoints. 

 

We're working on an update to allow some additional shipping information for our service to be sent along with the data: Whether an address has a lift gate, or has restricted access (both will affect shipping costs). Neither of these fields are in Shopify, so we are adding the UI of two radio selectors with javascript. Then, when the user changes the settings for one of these with javascript, we are using the Shopify AJAX /cart/change.js endpoint to add the customer extra shipping settings as properties on the cart's line items. The reason we are doing this is there doesn't seem to be any other way to get additional information about the customer's current cart through to the CarrierService. We're already using this method to get additional information about shipping, for instance inventory quantity and whether they would prefer items be shipped separately or together. Those properties are getting through to the CarrierService just fine, but they are inserted from the cart page instead of the checkout.

 

AJAX updates to the cart from made the checkout, however, don't seem to effectively update the line items within the checkout flow. If I use a GET /cart.js AJAx call from the console, the line items are showing up with the newly added properties. However, the CarrierService doesn't seem to get these newly added line item properties (it does receive the ones we add prior to checkout), and these new attributes also do not show up in the line item attributes in the order history. If I leave the checkout and return to the cart, then re-enter the checkout, I am correctly seeing these line item attributes and the CarrierService will see them as well.

 

We're looking for any advice for whether there is a way to update line item properties from within the checkout that will be accurately reflected without leaving and reentering the checkout. Failing that, I'm interested if there would be any other way for the front end of the checkout to make updates for the purposes of custom shipping quotes that will be accessible through the CarrierService endpoint. Because this information directly relates to the shipping address, it doesn't make sense to require this information before they enter the checkout flow.

0 Likes
Shopify Staff
Shopify Staff
1555 79 245

Hey @trecord.

 

While I can say that unfortunately I don't have any alternatives to offer besides using line item properties, and we don't currently offer a solution to effectively update those line item properties from the checkout without having to leave and re-enter the checkout, your feedback is heard loud and clear.

 

I'll make sure to pass that along for future considerations for the shipping team. If someone from the community has found a maybe less conventional approach to solving this problem, I of course welcome those kinds of answers to this thread too.

 

Sorry I couldn't give you more on this one, at least I can make sure your concerns are heard.

 

Cheers.

0 Likes
New Member
5 0 0

What we're going to do for the moment is append the extra information that we want to sent in a JSON format on the end of the address2 line. 

$(document).on('submit','form.edit_checkout',(e) => {
  insertJSONtoAddressAddress();
});

function insertJSONtoAddressAddress() {
  if($("#checkout_shipping_address_address2").length){
    const extraData = '{dataOne:true, dataTwo:false}';
    const currentAddress2 = $("#checkout_shipping_address_address2").val();
    $("#checkout_shipping_address_address2").val(`${currentAddress2};${extraData}`);
  }
}

 

Then we simply use javascript hide this on every page that shows an address during the checkout. This would not be a great option for everyone, because this will still mean that the extra JSON will appear in a confirmation emails and in order histories. Also the page will often "repaint," so it has to re-hide that information every time that happens.

0 Likes
New Member
3 0 0

I have worked with magento , opencart, prestashop, woocommerce platforms about checkout is great. but with shopify it's really bad, you can't calculate shipping prices. Too bad for a CMS

0 Likes
New Member
3 0 0

Your goal is to calculate the shipping cost in kilometers, right?
And description for that shipping fee.

 

note.png

 

You use callback_url after adding carrier, at page checkout shopify page will call callback_url to get shipping method.

{
"rates": [
{
"service_name": "UPS Shipping",
"service_code": "ups_shipping",
"total_price": "1500",
"description": "This is the fastest option by far",
"currency": "USD",
"min_delivery_date": "2019-07-19 14:48:45 -0400",
"max_delivery_date": "2019-07-21 14:48:45 -0400"
},
{
"service_name": "UPS Shipping 2",
"service_code": "ups_shipping_2",
"total_price": "1100",
"description": "This is description",
"currency": "USD",
"min_delivery_date": "2019-07-19 14:48:45 -0400",
"max_delivery_date": "2019-07-21 14:48:45 -0400"
}
]
}

 

0 Likes
New Member
6 0 0

hi shopify page not egtting my callback url how i can debug .Please help me i am stucked

0 Likes
New Member
5 0 0

No we're actually trying to capture additional shipping information unrelated to distance. IE we want to calculate additional cost for locations that have security checks, etc.

0 Likes