Customer Update webhook being called on Customer creation

Solved

Customer Update webhook being called on Customer creation

AnuragM
Shopify Partner
3 0 0

Hello Everyone,

 

I have created a third-party app to handle webhooks and "Customer update" is the only webhook i am working with. The issue i am facing is, whenever a new customer is created, along with customer creation webhook, the customer update webhook is also being triggered. Is this the default behaviour in Shopify? If yes then what is the best solution to this problem since i only want to work with customer update webhook.

 

Thanks.

Accepted Solution (1)

Shabalinski___A
Shopify Partner
21 4 2

This is an accepted solution.

Hi, @AnuragM!

 

I think this is default Shopify behavior.

 

Just add a handler to the desired webhook, with a little 'hack' to check that the 'customers/update' webhook is called when you update customers and not when you create customers:

Shopify.Webhooks.Registry.addHandler("CUSTOMERS_UPDATE", {
    path: "/webhooks",
    webhookHandler: async (topic, shop, body) => {
      const {created_at, updated_at} = body;

      if (created_at !== updated_at) {
        // your logic
      }
  },
});

but it looks like an Shopify issue

 

I hope this helps. If not, describe the problem in a little more detail, with code examples.

Have a nice day! 😉

Frontend (Shopify) Engineer at SpiralScout

  • - Was my reply helpful? Click Like to let me know!
  • - Was your question answered? Mark it as an Accepted Solution!

View solution in original post

Replies 4 (4)

Shabalinski___A
Shopify Partner
21 4 2

This is an accepted solution.

Hi, @AnuragM!

 

I think this is default Shopify behavior.

 

Just add a handler to the desired webhook, with a little 'hack' to check that the 'customers/update' webhook is called when you update customers and not when you create customers:

Shopify.Webhooks.Registry.addHandler("CUSTOMERS_UPDATE", {
    path: "/webhooks",
    webhookHandler: async (topic, shop, body) => {
      const {created_at, updated_at} = body;

      if (created_at !== updated_at) {
        // your logic
      }
  },
});

but it looks like an Shopify issue

 

I hope this helps. If not, describe the problem in a little more detail, with code examples.

Have a nice day! 😉

Frontend (Shopify) Engineer at SpiralScout

  • - Was my reply helpful? Click Like to let me know!
  • - Was your question answered? Mark it as an Accepted Solution!
AnuragM
Shopify Partner
3 0 0

Hey @Shabalinski___A ,

 

Will try this out now. Thanks for the solution. Have a great day! 😄

Shabalinski___A
Shopify Partner
21 4 2

Let me ask you, @AnuragM, did my decision help you?

Frontend (Shopify) Engineer at SpiralScout

  • - Was my reply helpful? Click Like to let me know!
  • - Was your question answered? Mark it as an Accepted Solution!
AnuragM
Shopify Partner
3 0 0

Yes it did work. Thanks for this solution @Shabalinski___A