Empty line_items JSON data in Carts/create Webhook

Solved
LifeFashionBtq
New Member
1 0 0

I've created a Webhook notification for Carts create, in order to involving this message into my work flow, for example, forward a message in my slack channel.

This Webhook works fine most of the times, but still sometimes I've got empty line_items JSON data fired.

 {
    "created_at":"2021-03-15T10:26:40.724Z",
    "id":"ID",
    "line_items":[],
    "note":null,
    "token":"TOKEN",
    "updated_at":"2021-03-15T10:27:27.384Z"
}

 

My question would be, when and why those empty line items json data will be fired?

0 Likes
_JCC_
Shopify Staff
Shopify Staff
158 21 27

This is an accepted solution.

Hey @LifeFashionBtq ,

The cart/create web hooks received with empty line items could be a couple of things.

1. If the user visits the cart page, and no cart has been created, a cart will be created automatically with no line items.

2. If there's use of the Ajax Cart API, and a request was made to get the current cart and one doesn't exist, a cart will be created with no line items.

Hope that helps, if you have any other questions please don't hesitate to reach out.

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog