cmxsevenfoldxmc Posted July 21, 2009 Share Posted July 21, 2009 Hi there, I keep getting this T_CASE error and after numerous attempts to find the error, I can't seem to find where the error is. Can anyone see what I'm missing? case 'copy_to_confirm': if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) { $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); if ($HTTP_POST_VARS['copy_as'] == 'link') { if ($categories_id != $current_category_id) { $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'"); $check = tep_db_fetch_array($check_query); if ($check['total'] < '1') { tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')"); } } else { $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error'); } } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') { // BOF QPBPP for SPPC: products_qty_blocks, products_min_order_qty added $product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id, products_qty_blocks, products_min_order_qty from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $product = tep_db_fetch_array($product_query); tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_qty_blocks, products_min_order_qty) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "', '" . (int)$product['products_qty_blocks'] . "', '" . (int)$product['products_min_order_qty'] . "')"); // EOF QPBPP for SPPC $dup_products_id = tep_db_insert_id(); $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'"); while ($description = tep_db_fetch_array($description_query)) { tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')"); } tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')"); // BOF Separate Pricing Per Customer adapted for QPBPP for SPPC $cg_price_query = tep_db_query("select customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_id . "' order by customers_group_id"); // insert customer group prices in table products_groups when there are any for the copied product // adapted for QPBPP for SPPC if (tep_db_num_rows($cg_price_query) > 0) { while ( $cg_prices = tep_db_fetch_array($cg_price_query)) { tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (customers_group_id, customers_group_price, products_id, products_qty_blocks, products_min_order_qty) values ('" . (int)$cg_prices['customers_group_id'] . "', " . (empty($cg_prices['customers_group_price']) ? "null" : "'" . tep_db_input($cg_prices['customers_group_price']) . "'") . ", '" . (int)$dup_products_id . "', '" . (int)$cg_prices['products_qty_blocks'] . "', '" . (int)$cg_prices['products_min_order_qty'] . "')"); } // end while ( $cg_prices = tep_db_fetch_array($cg_price_query)) } // end if (tep_db_num_rows($cg_price_query) > 0) $price_breaks_query = tep_db_query("select products_price, products_qty, customers_group_id from " . TABLE_PRODUCTS_PRICE_BREAK . " where products_id = '" . (int)$products_id . "' order by customers_group_id, products_qty"); while ($price_break = tep_db_fetch_array($price_breaks_query)) { $sql_price_break_data_array = array( 'products_id' => (int)$dup_products_id, 'products_price' => $price_break['products_price'], 'products_qty' => $price_break['products_qty'], 'customers_group_id' => $price_break['customers_group_id']); tep_db_perform(TABLE_PRODUCTS_PRICE_BREAK, $sql_price_break_data_array); } $current_dc_query = tep_db_query("select discount_categories_id, customers_group_id from " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " where products_id = '" . (int)$products_id . "' order by customers_group_id"); if (tep_db_num_rows($current_dc_query) > 0) { // insert the new products_id in products_to_discount_categories only // if the cloned product was already in it while ($current_dc = tep_db_fetch_array($current_dc_query)) { $discount_category_result = qpbpp_insert_update_discount_cats($dup_products_id, '0', $current_dc['discount_categories_id'], $current_dc['customers_group_id']); if ($discount_category_result == false) { $messageStack->add_session(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error'); } } // end while ($current_dc = .... } // end if (tep_db_num_rows($current_dc_query) // EOF Separate Pricing Per Customer adapted for QPBPP for SPPC $products_id = $dup_products_id; } if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id)); break; Thank you very much in advance! I'm in desperate need of this code to work Quote Link to comment Share on other sites More sharing options...
Guest Posted July 22, 2009 Share Posted July 22, 2009 You need to post the whole code. The portion you posted does not have errors. Quote Link to comment Share on other sites More sharing options...
cmxsevenfoldxmc Posted July 23, 2009 Author Share Posted July 23, 2009 You need to post the whole code. The portion you posted does not have errors. Here's the top code for that page (Before <html.....>). I've reviewed it a few times and have found nothing but I might just be skipping small details. Any ideas on what it could be? Thanks in advance! <?php /* $Id: categories.php,v 1.146 2003/07/11 14:40:27 hpdl Exp $ adapted for Separate Pricing Per Customer v4.2 2007/08/05, QPBPP for SPPC v2.0 2008/11/23 adapted for Separate Pricing Per Customer v4.2 2007/08/05, Hide products and categories from groups 2008/08/03 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies(); // BOF QPBPP for SPPC // include the admin version of price formatter for the price breaks contribution require(DIR_WS_CLASSES . 'PriceFormatterAdmin.php'); $pf = new PriceFormatter; // EOF QPBPP for SPPC $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''); if (tep_not_null($action)) { switch ($action) { case 'setflag': if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) { if (isset($HTTP_GET_VARS['pID'])) { tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']); } if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID'])); break; case 'insert_category': case 'update_category': if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); // BOF Separate Pricing Per Customer, hide categories from groups $hide_cats_from_these_groups = '@,'; if ( $HTTP_POST_VARS['hide_cat'] ) { // if any of the checkboxes are checked foreach($HTTP_POST_VARS['hide_cat'] as $val) { $hide_cats_from_these_groups .= tep_db_prepare_input($val).','; } // end foreach } $hide_cats_from_these_groups = substr($hide_cats_from_these_groups,0,strlen($hide_cats_from_these_groups)-1); // remove last comma $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']); $sql_data_array = array('sort_order' => $sort_order, 'categories_hide_from_groups' => $hide_cats_from_these_groups); // EOF Separate Pricing Per Customer, hide categories from groups if ($action == 'insert_category') { $insert_sql_data = array('parent_id' => $current_category_id, 'date_added' => 'now()'); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_CATEGORIES, $sql_data_array); $categories_id = tep_db_insert_id(); } elseif ($action == 'update_category') { $update_sql_data = array('last_modified' => 'now()'); $sql_data_array = array_merge($sql_data_array, $update_sql_data); tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'"); } $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $categories_name_array = $HTTP_POST_VARS['categories_name']; $language_id = $languages[$i]['id']; $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id])); if ($action == 'insert_category') { $insert_sql_data = array('categories_id' => $categories_id, 'language_id' => $languages[$i]['id']); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array); } elseif ($action == 'update_category') { tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'"); } } if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) { tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'"); } if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id)); break; case 'delete_category_confirm': if (isset($HTTP_POST_VARS['categories_id'])) { $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); $categories = tep_get_category_tree($categories_id, '', '0', '', true); $products = array(); $products_delete = array(); for ($i=0, $n=sizeof($categories); $i<$n; $i++) { $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'"); while ($product_ids = tep_db_fetch_array($product_ids_query)) { $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id']; } } reset($products); while (list($key, $value) = each($products)) { $category_ids = ''; for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) { $category_ids .= "'" . (int)$value['categories'][$i] . "', "; } $category_ids = substr($category_ids, 0, -2); $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")"); $check = tep_db_fetch_array($check_query); if ($check['total'] < '1') { $products_delete[$key] = $key; } } // removing categories can be a lengthy process tep_set_time_limit(0); for ($i=0, $n=sizeof($categories); $i<$n; $i++) { tep_remove_category($categories[$i]['id']); } reset($products_delete); while (list($key) = each($products_delete)) { tep_remove_product($key); } } if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath)); break; case 'delete_product_confirm': if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) { $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); $product_categories = $HTTP_POST_VARS['product_categories']; for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) { tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'"); // BOF Separate Pricing Per Customer tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . tep_db_input($product_id) . "' "); // EOF Separate Pricing Per Customer } // BOF QPBPP for SPPC tep_db_query("delete from " . TABLE_PRODUCTS_PRICE_BREAK . " where products_id = '" . (int)$product_id . "'"); // EOF QPBPP for SPPC $product_categories_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'"); $product_categories = tep_db_fetch_array($product_categories_query); if ($product_categories['total'] == '0') { tep_remove_product($product_id); } } if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath)); break; case 'move_category_confirm': if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) { $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']); $path = explode('_', tep_get_generated_category_path_ids($new_parent_id)); if (in_array($categories_id, $path)) { $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error'); tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id)); } else { tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'"); if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id)); } } break; case 'move_product_confirm': $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']); $duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$new_parent_id . "'"); $duplicate_check = tep_db_fetch_array($duplicate_check_query); if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'"); if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id)); break; case 'insert_product': case 'update_product': if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) { $action = 'new_product'; } else { if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']); $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']); $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null'; // BOF Separate Pricing Per Customer, hide products and categories from groups $hide_from_these_groups = '@,'; if ( $HTTP_POST_VARS['hide'] ) { // if any of the checkboxes are checked foreach($HTTP_POST_VARS['hide'] as $val) { $hide_from_these_groups .= tep_db_prepare_input($val).','; } // end foreach } $hide_from_these_groups = substr($hide_from_these_groups,0,strlen($hide_from_these_groups)-1); // remove last comma // EOF Separate Pricing Per Customer, hide products and categories from groups $sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']), 'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']), 'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']), // BOF QPBPP for SPPC 'products_qty_blocks' => (($i = (int)tep_db_prepare_input($_POST['products_qty_blocks'][0])) < 1) ? 1 : $i, 'products_min_order_qty' => (($min_i = (int)tep_db_prepare_input($_POST['products_min_order_qty'][0])) < 1) ? 1 : $min_i, // EOF QPBPP for SPPC 'products_date_available' => $products_date_available, 'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']), 'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']), 'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']), // BOF Separate Price Per Customer, hide for these groups modification 'products_hide_from_groups' => $hide_from_these_groups, // EOF Separate Price Per Customer, hide for these groups modification 'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id'])); if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) { $sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']); } if ($action == 'insert_product') { $insert_sql_data = array('products_date_added' => 'now()'); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_PRODUCTS, $sql_data_array); $products_id = tep_db_insert_id(); tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')"); } elseif ($action == 'update_product') { $update_sql_data = array('products_last_modified' => 'now()'); $sql_data_array = array_merge($sql_data_array, $update_sql_data); tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'"); } // BOF QPBPP for SPPC // BOF entries in products_groups // the query is changed to also get the results for group 0 (retail) // so that the results of the query can be used for the hide products mod too $customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id"); while ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups { if (tep_db_num_rows($customers_group_query) > 0) { // store results in an array here for the hide product modification $_hide_customers_group[] = $customers_group; // if customer group is retail we stop here and continue with the next group if ($customers_group['customers_group_id'] == 0) continue; $attributes_query = tep_db_query("select customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id"); $attributes = tep_db_fetch_array($attributes_query); // set default values for quantity blocks and min order quantity $pg_products_qty_blocks = 1; $pg_products_min_order_qty = 1; $delete_row_from_pg = false; if (isset($_POST['products_qty_blocks'][$customers_group['customers_group_id']]) && (int)$_POST['products_qty_blocks'][$customers_group['customers_group_id']] > 1) { $pg_products_qty_blocks = (int)$_POST['products_qty_blocks'][$customers_group['customers_group_id']]; } if (isset($_POST['products_min_order_qty'][$customers_group['customers_group_id']]) && (int)$_POST['products_min_order_qty'][$customers_group['customers_group_id']] > 1) { $pg_products_min_order_qty = (int)$_POST['products_min_order_qty'][$customers_group['customers_group_id']]; } if ($_POST['sppcprice'][$customers_group['customers_group_id']] == '' && $pg_products_qty_blocks == 1 && $pg_products_min_order_qty == 1) { $delete_row_from_pg = true; // no need to have default values for qty blocks and min order qty in the table } if ($_POST['sppcprice'][$customers_group['customers_group_id']] == '') { $pg_cg_group_price = 'null'; } else { $pg_cg_group_price = "'" . (float)$_POST['sppcprice'][$customers_group['customers_group_id']] . "'"; } if (tep_db_num_rows($attributes_query) > 0 && $delete_row_from_pg == false) { // there is already a row inserted in products_groups, update instead of insert if ($_POST['sppcoption'][$customers_group['customers_group_id']]) { // this is checking if the check box is checked tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = " . $pg_cg_group_price . ", products_qty_blocks = " . $pg_products_qty_blocks . ", products_min_order_qty = " . $pg_products_min_order_qty . " where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'"); } else { tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'"); } } elseif (tep_db_num_rows($attributes_query) > 0 && $delete_row_from_pg == true) { tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'"); } elseif (($_POST['sppcoption'][$customers_group['customers_group_id']]) && $delete_row_from_pg == false) { tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', " . $pg_cg_group_price . ", " . $pg_products_qty_blocks . ", " . $pg_products_min_order_qty . ")"); } } // end while ($customers_group = tep_db_fetch_array($customers_group_query)) // EOF entries in products_groups // BOF entries in products_to_discount_categories foreach ($_POST['discount_categories_id'] as $dc_cg_id => $dc_id) { $current_discount_category = (int)$_POST['current_discount_cat_id'][$dc_cg_id]; $new_discount_category = (int)$dc_id; $discount_category_result = qpbpp_insert_update_discount_cats($products_id, $current_discount_category, $new_discount_category, $dc_cg_id); if ($discount_category_result == false) { $messageStack->add_session(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error'); } } // end foreach ($_POST['discount_categories_id'] as $dc_cg_id => $dc_id // EOF entries in products_to_discount_categories // BOF entries in products_price_break foreach ($_POST['products_price_break'] as $pbb_cg_id => $price_break_array) { foreach ($price_break_array as $key1 => $products_price) { $pb_action = 'insert'; // re-set default to insert $where_clause = ''; if (isset($_POST['products_delete'][$pbb_cg_id][$key1]) && $_POST['products_delete'][$pbb_cg_id][$key1] == 'y' && isset($_POST['products_price_break_id'][$pbb_cg_id][$key1])) { $delete_from_ppb_array[] = (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1]; continue; } if (!tep_not_null($products_price)) { continue; // if price is empty this price break is unused } elseif (!tep_not_null($_POST['products_qty'][$pbb_cg_id][$key1])) { continue; // if qty is not entered we will not update or insert this in the table } else { $sql_price_break_data_array = array( 'products_id' => (int)$products_id, 'products_price' => (float)$products_price, 'products_qty' => (int)$_POST['products_qty'][$pbb_cg_id][$key1], 'customers_group_id' => $pbb_cg_id ); if (isset($_POST['products_price_break_id'][$pbb_cg_id][$key1]) && (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1] > 0) { $pb_action = 'update'; $where_clause = " products_price_break_id = '" . (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1] . "'"; } tep_db_perform(TABLE_PRODUCTS_PRICE_BREAK, $sql_price_break_data_array, $pb_action, $where_clause); } // end if/else (!tep_not_null($products_price)) } // end foreach ($price_break_array as $key1 => $products_price) } // end foreach ($_POST['products_price_break'] as $pbb_cg_id => $price_break_array) // delete the unwanted price breaks using their products_price_break_id's if (isset($delete_from_ppb_array) && sizeof($delete_from_ppb_array > 0) && tep_not_null($delete_from_ppb_array[0])) { tep_db_query("delete from " . TABLE_PRODUCTS_PRICE_BREAK . " where products_price_break_id in (" . implode(',', $delete_from_ppb_array) . ")"); } // EOF entries in products_price_break // EOF QPBPP for SPPC $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $language_id = $languages[$i]['id']; $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]), 'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]), 'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id])); if ($action == 'insert_product') { $insert_sql_data = array('products_id' => $products_id, 'language_id' => $language_id); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array); } elseif ($action == 'update_product') { tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'"); } } if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id)); } break; case 'copy_to_confirm': if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) { $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); if ($HTTP_POST_VARS['copy_as'] == 'link') { if ($categories_id != $current_category_id) { $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'"); $check = tep_db_fetch_array($check_query); if ($check['total'] < '1') { tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')"); } } else { $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error'); } } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') { // BOF QPBPP for SPPC: products_qty_blocks, products_min_order_qty added $product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id, p.products_hide_from_groups products_qty_blocks, products_min_order_qty from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $product = tep_db_fetch_array($product_query); tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, p.products_hide_from_groups, products_qty_blocks, products_min_order_qty) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "', '" . (int)$product['products_qty_blocks'] . "', '" . (int)$product['products_min_order_qty'] . "')"); // EOF QPBPP for SPPC $dup_products_id = tep_db_insert_id(); $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'"); while ($description = tep_db_fetch_array($description_query)) { tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')"); } tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')"); // BOF Separate Pricing Per Customer adapted for QPBPP for SPPC $cg_price_query = tep_db_query("select customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_id . "' order by customers_group_id"); // insert customer group prices in table products_groups when there are any for the copied product // adapted for QPBPP for SPPC if (tep_db_num_rows($cg_price_query) > 0) { while ( $cg_prices = tep_db_fetch_array($cg_price_query)) { tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (customers_group_id, customers_group_price, products_id, products_qty_blocks, products_min_order_qty) values ('" . (int)$cg_prices['customers_group_id'] . "', " . (empty($cg_prices['customers_group_price']) ? "null" : "'" . tep_db_input($cg_prices['customers_group_price']) . "'") . ", '" . (int)$dup_products_id . "', '" . (int)$cg_prices['products_qty_blocks'] . "', '" . (int)$cg_prices['products_min_order_qty'] . "')"); } // end while ( $cg_prices = tep_db_fetch_array($cg_price_query)) } // end if (tep_db_num_rows($cg_price_query) > 0) $price_breaks_query = tep_db_query("select products_price, products_qty, customers_group_id from " . TABLE_PRODUCTS_PRICE_BREAK . " where products_id = '" . (int)$products_id . "' order by customers_group_id, products_qty"); while ($price_break = tep_db_fetch_array($price_breaks_query)) { $sql_price_break_data_array = array( 'products_id' => (int)$dup_products_id, 'products_price' => $price_break['products_price'], 'products_qty' => $price_break['products_qty'], 'customers_group_id' => $price_break['customers_group_id']); tep_db_perform(TABLE_PRODUCTS_PRICE_BREAK, $sql_price_break_data_array); } $current_dc_query = tep_db_query("select discount_categories_id, customers_group_id from " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " where products_id = '" . (int)$products_id . "' order by customers_group_id"); if (tep_db_num_rows($current_dc_query) > 0) { // insert the new products_id in products_to_discount_categories only // if the cloned product was already in it while ($current_dc = tep_db_fetch_array($current_dc_query)) { $discount_category_result = qpbpp_insert_update_discount_cats($dup_products_id, '0', $current_dc['discount_categories_id'], $current_dc['customers_group_id']); if ($discount_category_result == false) { $messageStack->add_session(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error'); } } // end while ($current_dc = .... } // end if (tep_db_num_rows($current_dc_query) // EOF Separate Pricing Per Customer adapted for QPBPP for SPPC $products_id = $dup_products_id; } if (USE_CACHE == 'true') { tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased'); } } tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id)); break; case 'new_product_preview': // copy image only if modified $products_image = new upload('products_image'); $products_image->set_destination(DIR_FS_CATALOG_IMAGES); if ($products_image->parse() && $products_image->save()) { $products_image_name = $products_image->filename; } else { $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); } break; } } // check if the catalog image directory exists if (is_dir(DIR_FS_CATALOG_IMAGES)) { if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error'); } else { $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error'); } ?> Quote Link to comment Share on other sites More sharing options...
Guest Posted July 23, 2009 Share Posted July 23, 2009 (edited) Edited July 23, 2009 by lyonsperf Quote Link to comment Share on other sites More sharing options...
cmxsevenfoldxmc Posted July 23, 2009 Author Share Posted July 23, 2009 You had too many } in your code. You should use a program like Webuilder to check to see if the syntax is correct. It will point it out for you. Here is the corrected code: That helped out a lot! Thanks for that I can make it to the categories.php page, but this comes up now: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' p.products_qty_blocks, p.products_min_order_qty from products p, products_descr' at line 1 select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_hide_from_groups from, p.products_qty_blocks, p.products_min_order_qty from products p, products_description pd, products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = '23' order by pd.products_name Any idea why? I'm verifying it on my end too Quote Link to comment Share on other sites More sharing options...
Guest Posted July 23, 2009 Share Posted July 23, 2009 You have a mismatch in your sql. The query statement doesn't match the sql values. Check your values under the Products section of sql against the section in categories.php. You need to add the missing values i.e. p.products_ where they are missing. Quote Link to comment Share on other sites More sharing options...
♥ecartz Posted July 24, 2009 Share Posted July 24, 2009 It's this section: p.products_hide_from_groups from, p.products_qty_blocks should be p.products_hide_from_groups, p.products_qty_blocks without the extraneous from. Quote Always back up before making changes. Link to comment Share on other sites More sharing options...
cmxsevenfoldxmc Posted July 24, 2009 Author Share Posted July 24, 2009 That worked like a charm! I can't believe I missed that "from" so many times lol! Thanks again guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.