function smn_delete_store($prefix) { global $languages; if ($prefix != '') { $DB_tables = array(TABLE_CATEGORIES, TABLE_CATEGORIES_DESCRIPTION, TABLE_CONFIGURATION, TABLE_LANGUAGES, TABLE_NEWSLETTERS, TABLE_ORDERS_TRACKING, TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD, TABLE_PRODUCTS_NOTIFICATIONS, TABLE_PRODUCTS_OPTIONS, TABLE_PRODUCTS_OPTIONS_VALUES, TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS, TABLE_REVIEWS, TABLE_REVIEWS_DESCRIPTION, TABLE_TAX_CLASS, TABLE_TAX_RATES, TABLE_GEO_ZONES, TABLE_ZONES_TO_GEO_ZONES, TABLE_ARTICLES, TABLE_WEB_SITE_CONTENT, TABLE_DYNAMIC_PAGE_INDEX, TABLE_STORE_NAMES, TABLE_STORE_COSTS, TABLE_STORE_OWNER_DATA, TABLE_STORE_TO_CATEGORIES, TABLE_STORE_DESCRIPTION, TABLE_STORE_REVIEWS, TABLE_MEMBER_ORDERS); foreach ($DB_tables as $table_name) { //delete all DB table rows associated with the store.... smn_db_query("delete from " . $table_name . " WHERE store_id = '" . $prefix . "'"); if ($db_error) { return $db_error; } } /* " . TABLE_SAVED_ORDERS . ", " . TABLE_SAVED_ORDERS_PRODUCTS . ", " . TABLE_SAVED_ORDERS_PRODUCTS_ATTRIBUTES . ", */ //remove products from system $product_categories_query = smn_db_query("select products_id from " . TABLE_PRODUCTS . " where store_id = '" . (int) $prefix . "'"); while ($product_categories = smn_db_fetch_array($product_categories_query)) { smn_remove_product($product_categories['product_id']); } //remove orders from system $store_orders_query = smn_db_query("select orders_id from " . TABLE_ORDERS . " where store_id = '" . (int) $prefix . "'"); while ($store_orders = smn_db_fetch_array($store_orders_query)) { smn_db_query("delete from " . TABLE_ORDERS_TRACKING . " WHERE orders_id = '" . $store_orders['orders_id'] . "'"); smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . $store_orders['orders_id'] . "'"); smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " WHERE orders_id = '" . $store_orders['orders_id'] . "'"); smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " WHERE orders_id = '" . $store_orders['orders_id'] . "'"); smn_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " WHERE orders_id = '" . $store_orders['orders_id'] . "'"); smn_db_query("delete from " . TABLE_ORDERS_TOTAL . " WHERE orders_id = '" . $store_orders['orders_id'] . "'"); } //delete the stores image directory and files from the system $dir = DIR_FS_CATALOG . 'images/' . $prefix . '_images'; smn_deldir($dir); /* //delete any saved orders in the DB tables associated with this store $saved_store_order_query = smn_db_query("select saved_order_id from " . TABLE_SAVED_ORDERS . " WHERE saved_store_id = '". $prefix_id ."'"); if (smn_db_num_rows($store_query)){ while ($saved_store_order = smn_db_fetch_array($saved_store_order_query)){ smn_db_query("delete from " . TABLE_SAVED_ORDERS_PRODUCTS . " where saved_order_id = '" . $saved_store_order['saved_order_id'] . "'"); if ($db_error) return ($db_error); smn_db_query("delete from " . TABLE_SAVED_ORDERS_PRODUCTS_ATTRIBUTES . " where saved_order_id = '" . $saved_store_order['saved_order_id'] . "'"); if ($db_error) return ($db_error); } smn_db_query("delete from " . TABLE_SAVED_ORDERS . " where saved_store_id = '". $prefix_id ."'"); if ($db_error) return ($db_error); }*/ } return $store_deleted = 'true'; }
smn_reset_cache_block('categories'); smn_reset_cache_block('also_purchased'); } smn_redirect(html_entity_decode(smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $cPath.'&ID='.$store_id))); break; case 'delete_product_confirm': if (isset($_POST['products_id']) && isset($_POST['product_categories']) && is_array($_POST['product_categories'])) { $product_id = smn_db_prepare_input($_POST['products_id']); $product_categories = $_POST['product_categories']; for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) { smn_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "' and store_id = '" .$store_id . "'"); } $product_categories_query = smn_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and store_id = '" .$store_id . "'"); $product_categories = smn_db_fetch_array($product_categories_query); if ($product_categories['total'] == '0') { smn_remove_product($product_id); } } if (USE_CACHE == 'true') { smn_reset_cache_block('categories'); smn_reset_cache_block('also_purchased'); } smn_redirect(html_entity_decode(smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $cPath.'&ID='.$store_id))); break; case 'move_category_confirm': if (isset($_POST['categories_id']) && ($_POST['categories_id'] != $_POST['move_to_category_id'])) { $categories_id = smn_db_prepare_input($_POST['categories_id']); $new_parent_id = smn_db_prepare_input($_POST['move_to_category_id']); $path = explode('_', smn_get_generated_category_path_ids($new_parent_id)); if (in_array($categories_id, $path)) { $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');
break; case 'deleteconfirm': $manufacturers_id = smn_db_prepare_input($_GET['mID']); if (isset($_POST['delete_image']) && $_POST['delete_image'] == 'on') { $manufacturer_query = smn_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $manufacturers_id . "'"); $manufacturer = smn_db_fetch_array($manufacturer_query); $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $manufacturer['manufacturers_image']; if (file_exists($image_location)) { @unlink($image_location); } } smn_db_query("delete from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $manufacturers_id . "'"); smn_db_query("delete from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int) $manufacturers_id . "'"); if (isset($_POST['delete_products']) && $_POST['delete_products'] == 'on') { $products_query = smn_db_query("select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int) $manufacturers_id . "'"); while ($products = smn_db_fetch_array($products_query)) { smn_remove_product($products['products_id']); } } else { smn_db_query("update " . TABLE_PRODUCTS . " set manufacturers_id = '' where manufacturers_id = '" . (int) $manufacturers_id . "'"); } if (USE_CACHE == 'true') { smn_reset_cache_block('manufacturers'); } smn_redirect(smn_href_link(FILENAME_MANUFACTURERS, 'page=' . $_GET['page'])); break; } } $content_page = basename($_SERVER['PHP_SELF']); require 'templates/default/layout.php'; require DIR_WS_INCLUDES . 'application_bottom.php';