Shopify: How to delete database entry fast after u

2019-08-17 04:52发布

问题:

This is my code in callbackController.php file

$url = 'https://' . $_GET['shop'] . '/admin/webhooks.json';                    
$webhookData = [
    'webhook' => [
        'topic' => 'app/uninstalled',
        'address' => config('app.url').'uninstall.php?shop='.$shop,
        'format' => 'json'
    ]
];
$uninstall = $sh->appUninstallHook($accessToken, $url, $webhookData);

This is my uninstall.php file code , these file is in laravel root folder.

$connection = new mysqli("localhost", "username", "******", "database");
$delete_shop = "DELETE FROM tablename WHERE store_name= '".$_GET['shop']."'";
$connection->query($delete_shop);    

I found solution here, but i can't understand how it works.

Thanks !!

回答1:

If you get an uninstall Webhook, there is no rush to suddenly delete the store from your DB before the merchant re-installs.

First off, merchants don't uninstall re-install Apps unless they are really outliers. Most just uninstall and never come back.

Second, if a merchant did uninstall, and then re-install, and you recognized their shop, they would be coming to you with a new token. You can therefore tell that this is a new install, and you could therefore decide to keep the same data, and just update the token, or do whatever you want.

But there is no need to rush to delete. That is you being the frog in the game Frogger :)