Shopify: How to delete database entry fast after uninstall web-hook response, so the merchant uninstall and re-install quickly?

孤者浪人 提交于 2019-12-24 19:23:13

问题


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 :)



来源:https://stackoverflow.com/questions/49686977/shopify-how-to-delete-database-entry-fast-after-uninstall-web-hook-response-so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!