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.

Empty line_items JSON data in Carts/create Webhook

Solved

Empty line_items JSON data in Carts/create Webhook

LifeFashionBtq
Visitor
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?

Accepted Solution (1)

_JCC_
Shopify Staff
200 27 58

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

View solution in original post

Reply 1 (1)

_JCC_
Shopify Staff
200 27 58

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