Customise XML Sent to Webhook/HTTP Post Request

New Member
17 0 0

Hi guys, we are using a fullfilment service and they have specific elements that need to be sent to them using the Webhook. Is it possible to add these lines to the XML that is sent somehow in Shopify? I have added the specific lines below in Bold that I am talking about. Any help would be greatly appreciated!

SalesID - BLANK
CustomerAccount – C98989999
ContactPersonID – 1293847444
DeliveryName
BillingName
DeliveryMode - USPS
ShipperServiceID - REGULAR
OrderDate
PaymentMode - BLANK
 
And for sales lines:
 
LineNumber – sequential line number for order lines
ItemID – 834834828488229
PartnerRefData - BLANK
Quantity
SalesPrice
LineAmount – Quantity * SalesPrice
DeliveryDate – 1/1/1900 (because it is unnecessary)

0 Likes
Highlighted
Shopify Staff
Shopify Staff
582 0 45

Sure. You handle the webhook, take your XML parser/generator of choice (my preference is Nokogiri) and add the fields you need.

Then proxy that data off to the fulfillment provider as needed.

Note: You should dump this into a background job so your server responds to the Shopify Webhooks promptly.

0 Likes
New Member
17 0 0

Thanks Chris. Ok, so are you saying I don't use any of Shopify's Web Hook system and I would create my own? Are you able to give me a bit more info on the steps I would need to take so we can try and work through it?

0 Likes
Shopify Staff
Shopify Staff
154 0 34

What Chris is saying: direct the Shopify webhook to your own, intermediate script. This way your script would act like a proxy. Here you would take the output of the Shopify webhook and add the fields you need, then send it off to the fulfilment service yourself. 

So like follows:

1) Something happens at Shopify 
2) A Shopify webhook triggers 
3) The webhooks sends its data to your scipt 
4) Your script picks up the data from the webhook 
5) Your script adds the fields to the XML/JSON
6) Your script sends the complete package to the fulfilment service
7) The fulfilment service parses your data


Hope this makes things a bit clearer.

1 Like
New Member
17 0 0

Hi guys. Progress on this, but I had a query. We have built our script, and all seems to work however the XML only sends to our script from Shopify once we login to the order and push the 'All line items fulfilled' button. Does this seem correct?

Or if we are using a fulfilment service should the XML send straight away the order is placed and once we get confirmation back from the fulfilment company we then hit the 'All line items fulfilled button'?

If it is the latter, any ideas why our XML would only send once this is clicked?

0 Likes
Shopify Staff
Shopify Staff
582 0 45

All webhooks are run via background workers so depending on the backlog of jobs, can take a little while to be delivered.

0 Likes
New Member
17 0 0

Thanks. So what I was wondering was the XML is ONLY sending from Shopify once we press the 'All line items fulfilled' button. This seems incorrect to me? Shouldn't the XML be sent when the order is placed and once it's sent from the Fulfilment company, we THEN press the 'All line items fulfilled' button?

0 Likes
Shopify Staff
Shopify Staff
582 0 45

I don't think I quite understand what you mean?

Is your app active as an "Official" fulfillment service? I.e. is the application installed as a fulfillment service or does it just create fulfillments for your orders?

0 Likes
New Member
17 0 0

We are using a fulfilment service. My question is, an order is placed on the site. The XML from Shopify ONLY sends the XML using the Webhook once we press the 'All line items fulfilled' button. But I don't think this is correct?

I imagine an order is placed and the XML should send to the fulfilment agency, THEN we should push the button on the order right?

0 Likes
Shopify Staff
Shopify Staff
582 0 45

That makes no sense at all. That means you could get fraudulent orders and they automatically get fulfilled, costing you a bunch of money in lost product because you were automatically fulfilling orders.

Clicking fulfill sends the fulfillment request off to the Fulfillment Gateway, and then the gateway will reply/post with the fulfillment information for the order.

You can probably inspect the order and verify that it's been marked as fulfilled but it shouldn't have any fulfillments attached to it yet.

0 Likes