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?
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.
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.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to delete a record
$sql = "DELETE FROM MyGuests WHERE id=3";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn->error;
}
$conn->close();
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With