Disable Customer via API

Highlighted
New Member
6 0 0

We have an app which merges customer accounts. Now after a source account is being merged into a primary account, the source account should be disabled.

This is to prevent account-sharing since we sell digital products.

We can't cancel the orders since they have already been fulfilled.

 

Scenario: Dude A purchases products, gives his account details to Dude B who could then merge the orders from Dude A. Therefore we would need some way of disabling A's account. This can be done in the Admin interface but I haven't found a way of doing it via the API.

 

Is this possible somehow?

If not, please regard this as a feature request. Thanks!

 

 

0 Likes
Shopify Expert
337 24 61

You can delete the source customer with the Customer API

 

If you have control of the app that manages the customer accounts, you can create a webhook to delete the customer after it's been merged into a new account.

 

If that app is 3rd party, you might be able to ask them if they have an API or can send a webhook to a private app - then in your private app, you can set it to make the Shopify API call to your store to delete the customer.

Founder of Speed Boostr (Shopify optimization and dev agency).
Creator of Order Automator (app that auto fulfills orders, adds tags, emails).
Creator of Shopify Analyzer (free performance analysis tool).
I also build custom apps and automated solutions.
Enjoy the adventure!
0 Likes
New Member
6 0 0

Hi Joe,

 

thanks for the reply!

That worked for some time, but with the release of version 2019-10 I get the error

 

422 Unprocessable Entity - Error deleting customer

every time that function is called. 

 

It may have been restricted recently since I can't recall the following comment was there before...and it worked up until one or two weeks ago

"A customer can't be deleted if they have existing orders" (although the source account does not have any orders after merging)

https://help.shopify.com/en/api/reference/customers/customer#destroy-2019-10

0 Likes
Shopify Expert
337 24 61

Aw man I hate when API update breaks functionality.

 

I guess you could continue using 2019-07 until this is resolved.

 

Or maybe instead of deleting, you can make a PUT request to change the email address, which would effectively disable anyone from using it. (assuming the customer knows to login to the new account so there's no friction)

Founder of Speed Boostr (Shopify optimization and dev agency).
Creator of Order Automator (app that auto fulfills orders, adds tags, emails).
Creator of Shopify Analyzer (free performance analysis tool).
I also build custom apps and automated solutions.
Enjoy the adventure!
0 Likes
New Member
6 0 0

Hey Joe,

 

funny thing is that it does not matter which API version I use, the error started appearing recently without me altering the version.

 

Anyway, a valid workaround for us is:

Try deleting the source order after it has been copied to the new account.

If that does not work (order placed on Shopify, not imported), cancel the fulfillment and then cancel the order. This will effectively remove the digital files for the customer account. 

 

Thanks again for your help!

0 Likes