Execute("select products_id from " . TABLE_PRODUCTS . " where products_model = '" . $model . "'"); $check_xsell = $db->Execute("select count(products_id) as records from " . TABLE_PRODUCTS_XSELL . " where products_id = '" . $products_id . "' and xsell_id = '" . $cross_product->fields['products_id'] . "'"); if ($check_xsell->fields['records'] > 0) { $messageStack->add_session(sprintf(CROSS_SELL_MODEL_ALREADY_ADDED, $model, $_POST['cross_product_model']), 'error'); } else { $insert_array = array('products_id' => $products_id, 'xsell_id' => $cross_product->fields['products_id'], 'sort_order' => '1' ); zen_db_perform(TABLE_PRODUCTS_XSELL, $insert_array); $messageStack->add_session(sprintf(CROSS_SELL_MODEL_ADDED, $model, $_POST['cross_product_model']), 'success'); } } switch($_GET['action']){ case 'confirm_delete_product': $db->Execute("delete from " . TABLE_PRODUCTS_XSELL . " where products_id = '" . (int)$_GET['cID'] . "'"); $messageStack->add(CROSS_SELL_PRODUCT_DELETETION_SUCCESS, 'success'); zen_redirect(zen_href_link(FILENAME_XSELL_ADVANCED, zen_get_all_get_params(array('action')))); break; case 'newcross_sell': if (!isset($_POST['cross_product_id']) ) { $product_lookup = $db->Execute("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd " . "where p.products_id = pd.products_id and pd.language_id ='".(int)$languages_id."' and p.products_model = '" . zen_db_prepare_input($_POST['cross_product_model']) . "'"); switch ($product_lookup->RecordCount()) { case '0': $messageStack->add_session(sprintf(CROSS_SELL_NO_MODEL_FOUND, $_POST['cross_product_model']), 'error'); zen_redirect(FILENAME_XSELL_ADVANCED); break; case '1': $products_id = $product_lookup->fields['products_id']; if (isset($_POST['product_model']) ) { foreach ($_POST['product_model'] as $id => $model) { if (zen_not_null($model) ) { add_new_cross_product($products_id, $model); } } } break; } } else { $products_id = $_POST['cross_product_id']; if (isset($_POST['product_model']) ) { foreach ($_POST['product_model'] as $id => $model) { if (zen_not_null($model) ) { add_new_cross_product($products_id, $model); } } } } zen_redirect(zen_href_link(FILENAME_XSELL_ADVANCED, 'cID=' . $products_id . '&action=edit')); break; case 'delete_cross': if (isset($_GET['xID']) ) { $db->Execute("delete from " . TABLE_PRODUCTS_XSELL . " where ID = '" . zen_db_prepare_input($_GET['xID']) . "'"); $messageStack->add_session(CROSS_SELL_PRODUCT_DELETED, 'success'); zen_redirect(zen_href_link(FILENAME_XSELL_ADVANCED, 'cID=' . $_GET['cID'] . '&action=edit')); } break; case 'editcross_sell': $product_lookup = $db->Execute("select p.products_id from " . TABLE_PRODUCTS . " p " . "where p.products_model = '" . zen_db_prepare_input($_POST['cross_product_model']) . "'"); if ($product_lookup->RecordCount() > 0) { zen_redirect(zen_href_link(FILENAME_XSELL_ADVANCED, 'cID=' . $product_lookup->fields['products_id'] . '&action=edit')); } $messageStack->add(sprintf(CROSS_SELL_PRODUCT_NOT_FOUND, $_POST['cross_product_model']), 'warning'); break; case 'update': $products_id = $_POST['cross_product_id']; if (isset($_POST['product_model']) ) { foreach ($_POST['product_model'] as $id => $model) { if (zen_not_null($model) ) { add_new_cross_product($products_id, $model); } } } zen_redirect(zen_href_link(FILENAME_XSELL_ADVANCED, 'cID=' . $products_id . '&action=edit')); break; case 'update_cross' : if ($_POST['product']){ foreach ($_POST['product'] as $temp_prod){ $db->execute('delete from ' . TABLE_PRODUCTS_XSELL . ' where xsell_id = "'.$temp_prod.'" and products_id = "'.$_GET['add_related_product_ID'].'"'); } } $sort_start_query = $db->execute('select sort_order from ' . TABLE_PRODUCTS_XSELL . ' where products_id = "'.$_GET['add_related_product_ID'].'" order by sort_order desc limit 1'); $sort_start = $sort_start_query->fields ; $sort = (($sort_start['sort_order'] > 0) ? $sort_start['sort_order'] : '0'); if ($_POST['cross']){ foreach ($_POST['cross'] as $temp){ $sort++; $insert_array = array(); $insert_array = array('products_id' => $_GET['add_related_product_ID'], 'xsell_id' => $temp, 'sort_order' => $sort); zen_db_perform(TABLE_PRODUCTS_XSELL, $insert_array); } } $messageStack->add(CROSS_SELL_SUCCESS, 'success'); break; case 'update_sort' : foreach ($_POST as $key_a => $value_a){ $db->execute('update ' . TABLE_PRODUCTS_XSELL . ' set sort_order = "' . $value_a . '" where xsell_id = "' . $key_a . '"'); } $messageStack->add(SORT_CROSS_SELL_SUCCESS, 'success'); break; } ?> > <?php echo TITLE; ?>
$value) { echo "Key $key => Value $value
"; } if (!isset($_POST['cross_product_id']) ) { $product_lookup = $db->Execute("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd " . "where p.products_id = pd.products_id and pd.language_id ='".(int)$languages_id."' and p.products_model = '" . zen_db_prepare_input($_POST['cross_product_model']) . "'"); switch ($product_lookup->RecordCount()) { case '0': echo 'Error: No Product Found

'; break; case '1': echo zen_draw_hidden_field('cross_product_id', $product_lookup->fields['products_id']); break; default: $product_array = array(); while(!$product_lookup->EOF) { echo $product_lookup->fields['products_name'] . '
'; $product_array[] = array('id' => $product_lookup->fields['products_id'], 'text' => $product_lookup->fields['products_name']); $product_lookup->MoveNext(); } echo zen_draw_pull_down_menu('cross_product_id', $product_array); break; } } echo 'New cross sell applied'; break; case 'delete': $product = $db->Execute("select p.products_model, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . zen_db_input($_GET['cID']) . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); ?>

Delete Confirmation

To confirm that you wish to delete the following item, please click confirm below.
fields['products_model'] . ' - ' . $product->fields['products_name']; ?>
' . zen_image_button('button_confirm.gif') . ''; ?>

New Cross-Sells

New Cross Sell








'; ?>



Edit Cross-Sells

Execute( "select p.products_id, p.products_model, pd.products_name, count(p.products_id) as xsells from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_XSELL . " px " . "where p.products_id = pd.products_id and p.products_id = px.products_id and pd.language_id ='".(int)$languages_id."' group by p.products_id"); if ($xsell_products->EOF) { echo 'No Cross Sells are currently active.'; } else { echo '
'; echo zen_draw_form('edit_cross', FILENAME_XSELL_ADVANCED, 'action=editcross_sell', 'post'); ?>
Edit Current Cross Sell


'; if ($_GET['action'] == 'edit') { $product_check = $db->Execute( "select p.products_id, p.products_model, pd.products_name, count(p.products_id) as xsells from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd " . "where p.products_id = pd.products_id and p.products_id = '" . (int)$_GET['cID'] . "' and pd.language_id ='".(int)$languages_id."' group by p.products_id"); $xsell_items = $db->Execute("select p.products_id, p.products_model, pd.products_name, px.ID from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_XSELL . " px " . "where p.products_id = pd.products_id and p.products_id = px.xsell_id and px.products_id = '" . (int)$_GET['cID'] . "' and pd.language_id ='".(int)$languages_id."' group by p.products_id"); echo zen_draw_form('new_cross', FILENAME_XSELL_ADVANCED, 'action=update', 'post'); echo zen_draw_hidden_field('cross_product_id', (int)$_GET['cID']); ?>
Product Cross-Sell for fields['products_model']; ?>
Product Name: fields['products_name']; ?>

'; echo ''; echo 'Product Model'; echo 'Product Name'; echo 'Action'; echo ''; while (!$xsell_items->EOF) { echo ''; echo '' . $xsell_items->fields['products_model'] . ''; echo '' . $xsell_items->fields['products_name'] . ''; echo ''; // echo '' . zen_image(DIR_WS_IMAGES . 'icons/admin_edit.gif', 'Edit') . ' '; echo '' . zen_image(DIR_WS_IMAGES . 'icons/delete.gif', 'Delete Cross-Sell') . ''; echo ''; echo ''; $xsell_items->MoveNext(); } echo ''; ?>








'; } ?>

Current Cross-Sells

'; echo ''; echo 'Product Model'; echo 'Product Name'; echo 'No. of Current Cross-Sells'; echo 'Action'; echo ''; while (!$xsell_products->EOF) { echo ''; echo '' . $xsell_products->fields['products_model'] . ''; echo '' . $xsell_products->fields['products_name'] . ''; echo '' . $xsell_products->fields['xsells'] . ''; echo ''; echo '' . zen_image_button('button_edit.gif', 'Edit Cross Sell') . ' '; echo '' . zen_image_button('button_delete.gif', 'Delete Cross Sell') . ''; echo ''; echo ''; $xsell_products->MoveNext(); } echo ''; ?>