I want the delete the store details from PHP Application after uninstalling the app from Shopify store which are stored in database when Application installed,
Now I got some solution for this like following:
$create_webhook = array('webhook'=>array(
'topic'=> 'app/uninstalled',
'address'=>'{{ mydomainname}}/uninstalled.php',
'format'=> 'json'
));
$request_update = $shopify('POST /admin/webhooks.json ', array(), $create_webhook);
But can we create this webhook at installing time or any other time?
3
Answers
Without knowing the schema it’s hard to tell what data you are trying to remove. If you’re able to provide an example of what data you’re inserting and what sort of columns are available we may be able to provide a bit more assistance.
Having said all that, it’s fairly straight forward to delete a row from a database. I assume you are looking for a script to delete something from a database, the below will do that. You need to update the SQL query to reflect your schema.
Your example code is registering a callback that will be accessed by the shopify uninstall webhook which will run when your app is uninstalled via the shopify admin UI. Make sure that “address” property is a public url to your applications uninstall callback.
Yes, you can register a callback for webhook at anytime.
When the app is uninstalled, shopify will send a POST request to the address you specified in the ‘address’ property with a json payload that has the customers details.
Take care to collect the X-Shopify-Hmac-SHA256 header and verify this is a genuine request before your callback deletes customer data.
Make sure you have all the data you need before the uninstall hook is run.
Uninstall revokes account tokens, removes registered webhooks and app data from shopify.
I have implemented this code to subscribe a webhook to an uninstall event of a Shopify App. I have created a custom shopify App in PHP. So here is the explanation step by step: