Re: Cart Attributes captured in Webhooks responses?

Cart Attributes captured in Webhooks responses?

Admin_Omtis
Visitor
3 0 0

I'm pretty sure the answer is affirmative, but I don't see any documentation / questions confirming this:

If I add additional cart attributes to the checkout form, will that information be passed to the Webhook response bodies?

Specifically the Order Created Webhook.

What key is the cart attribute stored at? note_attributes?

Appreciate any help!

Replies 5 (5)

Jason
Shopify Partner
11196 226 2287

will that information be passed to the Webhook response bodies?

Yes.

What key is the cart attribute stored at? note_attributes?

Yes. eg:

"note_attributes": [
  {
    "name": "foo",
    "value": "bar"
  }
]

If there's any concerns just create a quick order and you'll have the JSON ready to review via the webhook.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
JoshS
Shopify Partner
12 0 8

I am thinking about trying to use this method as a round-about way to get a `customer.id` in my webhook payloads for `cart/update` and `cart/create` (if a customer exists at that time). I have followed the instructions here as I think I understand them. For example, in our cart template (`cart.liquid`):

 
{% if customer %}
        <div class="cart-attribute__field">
          <input type="hidden" name="attributes[customer]" value="{{customer.id}}">
        </div>
{% endif %}

Then, in a private app, I'm registering a webhook like this:

const registerCartUpdateBody = {
    webhook: {
      topic: 'carts/update',
      address: `${tunnelURL}/shopify/cart/update`,
      format: 'json',
      fields: ['note_attributes']
    }
  };
  const registerCartUpdateOptions = {
    ...options,
    ...{
      method: 'POST',
      body: JSON.stringify(registerCartUpdateBody)
    }
  };

I can see that `note_attributes` is a registered field when I get back the webhook registration object (JSON), but I don't get back any value in my payloads from the cart update event. Is there something I'm not understanding or doing incorrectly? Thanks.

 
ldv-orbyta
Shopify Partner
1 0 0

Same issue

 

const cart_updated_hook = await Shopify.Webhooks.Registry.register(
{
shop,
accessToken,
path: "/webhooks",
topic: "CARTS_UPDATE",
fields: ['note_attributes']
}
);

I registered the webhook successfully but when I receive the response there isn't any attribute field in the json object. Did you solve your problem?

GustavoTofolo
Tourist
10 0 2

Hey Josh, did you solve it?

Admin_Omtis
Visitor
3 0 0

Hey Jason.

Thank you very much for your help! This is super.