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.

Re: webhook carts update missing key

webhook carts update missing key

lokki54
Shopify Partner
56 0 16

the carts/update webhook starts send the cartID without the recently started to be required key . example of the received data

"ShopifyApp"::"WebhooksController#receive as */*
  Parameters":{
   "id""=>""Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA",
   "token""=>""[FILTERED]",
   "line_items""=>"[
      {
         "id"=>39385543344183,
         "properties""=>nil",
         "quantity"=>2,
         "variant_id"=>39385543344183,
         "key""=>""39385543344183:f2b96a3f13539566d870d3dbccde355e",
         "discounted_price""=>""74.00",
         "discounts""=>"[
            
         ],
         "gift_card""=>false",
         "grams"=>356,
         "line_price""=>""148.00",
         "original_line_price""=>""148.00",
         "original_price""=>""74.00",
         "price""=>""74.00",
         "product_id"=>6573328171063,
         "sku""=>""",
         "taxable""=>true",
         "title""=>""LED High Tops - US 8",
         "total_discount""=>""0.00",
         "vendor""=>""Liam Fashions",
         "discounted_price_set""=>"{
            "shop_money""=>"{
               "amount""=>""74.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""74.0",
               "currency_code""=>""EUR"
            }
         },
         "line_price_set""=>"{
            "shop_money""=>"{
               "amount""=>""148.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""148.0",
               "currency_code""=>""EUR"
            }
         },
         "original_line_price_set""=>"{
            "shop_money""=>"{
               "amount""=>""148.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""148.0",
               "currency_code""=>""EUR"
            }
         },
         "price_set""=>"{
            "shop_money""=>"{
               "amount""=>""74.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""74.0",
               "currency_code""=>""EUR"
            }
         },
         "total_discount_set""=>"{
            "shop_money""=>"{
               "amount""=>""0.0",
               "currency_code""=>""EUR"
            },
            "presentment_money""=>"{
               "amount""=>""0.0",
               "currency_code""=>""EUR"
            }
         }
      }
   ],
   "note""=>""",
   "updated_at""=>""2024-09-02T13:23:17.863Z",
   "created_at""=>""2024-09-02T13:19:46.210Z",
   "type""=>""carts_update",
   "webhook""=>"{
      "id""=>""Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA",
      "token""=>""[FILTERED]",
      "line_items""=>"[
         {
            "id"=>39385543344183,
            "properties""=>nil",
            "quantity"=>2,
            "variant_id"=>39385543344183,
            "key""=>""39385543344183:f2b96a3f13539566d870d3dbccde355e",
            "discounted_price""=>""74.00",
            "discounts""=>"[
               
            ],
            "gift_card""=>false",
            "grams"=>356,
            "line_price""=>""148.00",
            "original_line_price""=>""148.00",
            "original_price""=>""74.00",
            "price""=>""74.00",
            "product_id"=>6573328171063,
            "sku""=>""",
            "taxable""=>true",
            "title""=>""LED High Tops - US 8",
            "total_discount""=>""0.00",
            "vendor""=>""Liam Fashions",
            "discounted_price_set""=>"{
               "shop_money""=>"{
                  "amount""=>""74.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""74.0",
                  "currency_code""=>""EUR"
               }
            },
            "line_price_set""=>"{
               "shop_money""=>"{
                  "amount""=>""148.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""148.0",
                  "currency_code""=>""EUR"
               }
            },
            "original_line_price_set""=>"{
               "shop_money""=>"{
                  "amount""=>""148.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""148.0",
                  "currency_code""=>""EUR"
               }
            },
            "price_set""=>"{
               "shop_money""=>"{
                  "amount""=>""74.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""74.0",
                  "currency_code""=>""EUR"
               }
            },
            "total_discount_set""=>"{
               "shop_money""=>"{
                  "amount""=>""0.0",
                  "currency_code""=>""EUR"
               },
               "presentment_money""=>"{
                  "amount""=>""0.0",
                  "currency_code""=>""EUR"
               }
            }
         }
      ],
      "note""=>""",
      "updated_at""=>""2024-09-02T13:23:17.863Z",
      "created_at""=>""2024-09-02T13:19:46.210Z"
   }
}

 

in the example above the id is the actual CartID. To get more cart details we use the the webhooks CartID in the 

query GetCartFromId

 

query = <<~QUERY
      query GetCartFromId($cartId: ID!) {
        cart(id: $cartId) {
          id
          createdAt
          updatedAt
          checkoutUrl
          lines(first: 100) {
            edges {
              node {
                id
                quantity
                merchandise {
                  ... on ProductVariant {
                    id
                    title
                    product {
                      id
                      vendor
                      collections(first: 10) {
                        edges {
                          node {
                            id
                            title
                          }
                        }
                      }
                      tags
                    }
                  }
                }
                estimatedCost {
                  subtotalAmount {
                    amount
                    currencyCode
                  }
                }
              }
            }
          }
          estimatedCost {
            subtotalAmount {
              amount
              currencyCode
            }
          }
          buyerIdentity {
            phone
            countryCode
            customer {
              id
              firstName
              email
              tags
            }
          }
        }
      }
    QUERY

    variables = { cartId: "gid://shopify/Cart/#{cart_token}" }

 

And in reply on some stores we get the cartID with the key

{
   "data""=>"{
      "cart""=>"{
         "id""=>""gid://shopify/Cart/Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA?key=50626e92045c56994cfaa7692b3bb8cf",
         "createdAt""=>""2024-09-02T13:19:46Z",
         "updatedAt""=>""2024-09-02T13:23:17Z",
         "checkoutUrl""=>""https://xstore.myshopify.com/cart/c/Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA?key=50626e92045c56994cfaa7692b3bb8cf",
         "lines""=>"{
            "edges""=>"[
               {
                  "node""=>"{
                     "id""=>""gid://shopify/CartLine/b50e4afc-2dec-4700-afab-5e55eb6b9946?cart=Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA",
                     "quantity"=>2,
                     "merchandise""=>"{
                        "id""=>""gid://shopify/ProductVariant/39385543344183",
                        "title""=>""US 8",
                        "product""=>"{
                           "id""=>""gid://shopify/Product/6573328171063",
                           "vendor""=>""Liam Fashions",
                           "collections""=>"{
                              "edges""=>"[
                                 {
                                    "node""=>"{
                                       "id""=>""gid://shopify/Collection/262448283703",
                                       "title""=>""Summer collection"
                                    }
                                 },
                                 {
                                    "node""=>"{
                                       "id""=>""gid://shopify/Collection/262470500407",
                                       "title""=>""new colleciton"
                                    }
                                 },
                                 {
                                    "node""=>"{
                                       "id""=>""gid://shopify/Collection/262479183927",
                                       "title""=>""My collection"
                                    }
                                 },
                                 {
                                    "node""=>"{
                                       "id""=>""gid://shopify/Collection/266991009847",
                                       "title""=>""Products"
                                    }
                                 },
                                 {
                                    "node""=>"{
                                       "id""=>""gid://shopify/Collection/266991042615",
                                       "title""=>""otherproducts"
                                    }
                                 }
                              ]
                           },
                           "tags""=>"[
                              "146897",
                              "147279",
                              "9891-014",
                              "men"
                           ]
                        }
                     },
                     "estimatedCost""=>"{
                        "subtotalAmount""=>"{
                           "amount""=>""148.0",
                           "currencyCode""=>""EUR"
                        }
                     }
                  }
               }
            ]
         },
         "estimatedCost""=>"{
            "subtotalAmount""=>"{
               "amount""=>""148.0",
               "currencyCode""=>""EUR"
            }
         },
         "buyerIdentity""=>"{
            "phone""=>nil",
            "countryCode""=>""DE",
            "customer""=>nil"
         }
      }
   }
}"in Shop xstore.myshopify.com"

 

 

However on some live stores the customers who has confirmed working app before starts to NOT RECEIVE a KEY in the query GetCartFromId($cartId: ID!) response

{
   "data""=>"{
      "cart""=>"{
         "id""=>""gid://shopify/Cart/Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA",
         "createdAt""=>""2024-09-02T13:19:46Z",
         "updatedAt""=>""2024-09-02T13:23:17Z",
         "checkoutUrl""=>""https://xstore.myshopify.com/cart/c/Z2NwLWV1cm9wZS13ZXN0MTowMUo2U0U4RDVDUUNYQ0RHN0NFMTdaQVlGMA",
         "lines""=>"{
            "edges""=>"[
               {
                  "node""=>"{

 

 

note 1: this was works fine before

note 2: some stores affected (2 confirmed live stores) and some are not like 2 my developer stores. 

 

Looks like Shopify starts to rollout some changes which brake functionality. 

 

note 3: my app was approved recently and it was working and passed all checks by the Shopify Validation Team.

 

So can you please someone from Shopify team get into this? Customers very unhappy

 

P.S

API version is 2024-04

 

Replies 2 (2)

milovanpinxtere
Shopify Partner
3 0 3

Same problem here, did you find a solution?

lokki54
Shopify Partner
56 0 16

No solution because the issue caused by shopify. They broke something. I found out more people confirm that issue affects randomly different stores