} } else { $update_sql = "UPDATE `app` SET `payment_status` = 'declined',`app_status` = 'uninstalled' WHERE `shop` = '" . $shop . "'"; if (mysql_query($update_sql)) { header("Location: index.php"); exit; } } } } else { try { $update_sql = "UPDATE `app` SET `payment_status` = 'accepted' WHERE `shop` = '" . $shop . "'"; mysql_query($update_sql); /* Webhook for App Uninstall Track */ $themes = $sc->call('GET', '/admin/themes.json'); $active_theme_arr = loopAndFind($themes, 'role', 'main'); $active_theme_id = $active_theme_arr[0]['id']; /* Webhook for App Uninstall Track */ try { $webhooks_arr = array("webhook" => array("topic" => "app/uninstalled", "address" => SITE_URL . "/hook.php", "format" => "json")); $resp = $sc->call('POST', "/admin/webhooks.json", $webhooks_arr); } catch (exception $e) { } /* Webhook for Order Create Hook */ try { $order_webhooks_arr = array("webhook" => array("topic" => "orders/create", "address" => SITE_URL . "/order_hook.php", "format" => "json")); $resp_o_hook = $sc->call('POST', "/admin/webhooks.json", $order_webhooks_arr); } catch (exception $e) { } /* Add Liquid File */ try {
$d_api_call_str = ""; if ($product_id_old != "") { $d_api_call_str = "/admin/products/" . $product_id_old . "/metafields/" . $upsell_meta_id . ".json"; } else { $d_api_call_str = "/admin/pages/" . $page_id_old . "/metafields/" . $upsell_meta_id . ".json"; } if ($d_api_call_str != "") { try { $delete_meta = $sc->call('DELETE', $d_api_call_str); } catch (exception $e) { } } } /* Delete meta for upsell type */ $upsell_meta_id_for_type = ""; $upsell_meta = loopAndFind($product_meta_list, 'namespace', 'b_share_viewer'); foreach ($upsell_meta as $k => $v) { if ($v['key'] == 'b_description_u') { $upsell_meta_id_for_type = $v['id']; } } if ($upsell_meta_id_for_type != "") { $d_api_call_str = ""; if ($product_id_old != "") { $d_api_call_str = "/admin/products/" . $product_id_old . "/metafields/" . $upsell_meta_id_for_type . ".json"; } else { $d_api_call_str = "/admin/pages/" . $page_id_old . "/metafields/" . $upsell_meta_id_for_type . ".json"; } if ($d_api_call_str != "") { try { $delete_meta = $sc->call('DELETE', $d_api_call_str);
$d_api_call_str = ""; if (strpos($old_upsell, 'p_') !== false) { $d_api_call_str = "/admin/products/" . $old_upsell_pro . "/metafields/" . $upsell_meta_id . ".json"; } else { $d_api_call_str = "/admin/custom_collections/" . $old_upsell_pro . "/metafields/" . $upsell_meta_id . ".json"; } if ($d_api_call_str != "") { try { $delete_meta = $sc->call('DELETE', $d_api_call_str); } catch (exception $e) { } } } /* Delete meta for upsell type */ $upsell_meta_id_for_type = ""; $upsell_meta = loopAndFind($product_meta_list, 'namespace', 'cu_upsell_type'); foreach ($upsell_meta as $k => $v) { if ($v['key'] == 'cu_upsell_value') { $upsell_meta_id_for_type = $v['id']; } } if ($upsell_meta_id_for_type != "") { $d_api_call_str = ""; if (strpos($old_upsell, 'p_') !== false) { $d_api_call_str = "/admin/products/" . $old_upsell_pro . "/metafields/" . $upsell_meta_id_for_type . ".json"; } else { $d_api_call_str = "/admin/custom_collections/" . $old_upsell_pro . "/metafields/" . $upsell_meta_id_for_type . ".json"; } if ($d_api_call_str != "") { try { $delete_meta = $sc->call('DELETE', $d_api_call_str);