Jump to content
Latest News: (loading..)

techhouse

Members
  • Content count

    10
  • Joined

  • Last visited

1 Follower

Profile Information

  • Real Name
    Rob
  1. techhouse

    Named anchor tags don't work?

    That works perfectly!
  2. techhouse

    Article Manager v1.0

    Here's a little update to offer Select All functionality to the Cross-Sell Articles to Products page: <?php /* $Id: articles_xsell.php,v 1.1 2006/03/07 08:42:49 tni001 Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Portions Copyright 2009 http://www.oscommerce-solution.com cross.sale.php created By Isaac Mualem im@imwebdesigning.com Modified by Andrew Edmond (osc@aravia.com) Sept 16th, 2002 Further Modified by Rob Anderson 12 Dec 03 Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_INCLUDES . 'template_top.php'); ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <!-- body_text //--> <td width="100%" valign="top"> <!-- Start of cross sale //--> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td align=left> <?php /* general_db_conct($query) function */ /* calling the function: list ($test_a, $test_b) = general_db_conct($query); */ function general_db_conct($query_1) { // $link = tep_db_connect(); $link = new mysqli(DB_SERVER,DB_SERVER_USERNAME,DB_SERVER_PASSWORD,DB_DATABASE); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } /* Select queries return a resultset */ if ($result_1 = mysqli_query($link, $query_1)) { $num_of_rows = mysqli_num_rows($result_1); $a_to_pass = array(); for ($i=0;$i<$num_of_rows;++$i) { $fields = mysqli_fetch_row($result_1); $a_to_pass[$i]= $fields[$y=0]; $b_to_pass[$i]= $fields[++$y]; $c_to_pass[$i]= $fields[++$y]; $d_to_pass[$i]= $fields[++$y]; $e_to_pass[$i]= $fields[++$y]; $f_to_pass[$i]= $fields[++$y]; $g_to_pass[$i]= $fields[++$y]; $h_to_pass[$i]= $fields[++$y]; $i_to_pass[$i]= $fields[++$y]; $j_to_pass[$i]= $fields[++$y]; $k_to_pass[$i]= $fields[++$y]; $l_to_pass[$i]= $fields[++$y]; $m_to_pass[$i]= $fields[++$y]; $n_to_pass[$i]= $fields[++$y]; $o_to_pass[$i]= $fields[++$y]; } return array($a_to_pass,$b_to_pass,$c_to_pass,$d_to_pass,$e_to_pass,$f_to_pass,$g_to_pass,$h_to_pass,$i_to_pass,$j_to_pass,$k_to_pass,$l_to_pass,$m_to_pass,$n_to_pass,$o_to_pass); /* free result set */ mysqli_free_result($result_1); } }//end of function // first major piece of the program // we have no instructions, so just dump a full list of products and their status for cross selling if (! isset($_GET['add_related_article_ID']) ) { $query = "select a.articles_id, ad.articles_name, ad.articles_description, ad.articles_url from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_DESCRIPTION . " ad where ad.articles_id = a.articles_id and ad.language_id = '" . (int)$languages_id . "' order by ad.articles_name"; list ($articles_id, $articles_name, $articles_description, $articles_url) = general_db_conct($query); ?> <table border="0" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" align="center" nowrap>ID</td> <td class="dataTableHeadingContent"><?php echo HEADING_ARTICLE_NAME; ?></td> <td class="dataTableHeadingContent" nowrap><?php echo HEADING_CROSS_ASSOCIATION; ?></td> <td class="dataTableHeadingContent" colspan="3" align="center" nowrap><?php echo HEADING_CROSS_SELL_ACTIONS; ?></td> </tr> <?php $num_of_articles = sizeof($articles_id); for ($i=0; $i < $num_of_articles; ++$i) { /* now we will query the DB for existing related items */ $query = "select pd.products_name, ax.xsell_id from " . TABLE_ARTICLES_XSELL . " ax, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = ax.xsell_id and ax.articles_id ='".$articles_id[$i]."' and pd.language_id = '" . (int)$languages_id . "' order by ax.sort_order"; list ($Related_items, $xsell_ids) = general_db_conct($query); echo "<tr bgcolor='#FFFFFF'>"; echo "<td class=\"dataTableContent\" valign=\"top\"> ".$articles_id[$i]." </td>\n"; echo "<td class=\"dataTableContent\" valign=\"top\"> ".$articles_name[$i]." </td>\n"; if ($Related_items) { echo "<td class=\"dataTableContent\"><ol>"; foreach ($Related_items as $display) echo '<li>'. $display .' '; echo"</ol></td>\n"; } else echo "<td class=\"dataTableContent\">--</td>\n"; echo '<td class="dataTableContent" valign="top"> <a href="' . tep_href_link(FILENAME_ARTICLES_XSELL, 'add_related_article_ID=' . $articles_id[$i], 'NONSSL') . '">Add/Remove</a></td>'; if (count($Related_items)>1) { echo '<td class="dataTableContent" valign="top"> <a href="' . tep_href_link(FILENAME_ARTICLES_XSELL, 'sort=1&add_related_article_ID=' . $articles_id[$i], 'NONSSL') . '">' . TEXT_SORT . '</a> </td>'; } else { echo "<td class=\"dataTableContent\" valign=top align=center>--</td>"; } echo "</tr>\n"; unset($Related_items); } ?> </table> <?php } // the end of -> if (!$_POST['add_related_article_ID']) if ($_POST && ! isset($_GET['sort'])) { if ($_POST['run_update']) { $ids = ' ( '; for ($x = 0; $x < count($_POST['xsell_id']); ++$x) { $ids .= ' xsell_id = ' . (int)$_POST['xsell_id'][$x] . ' or '; } $ids = substr($ids, 0, -3); $ids .= ' ) '; $ids = (count($_POST['xsell_id']) ? ' and ' . $ids : ''); //clear if list not present $query ="DELETE FROM " . TABLE_ARTICLES_XSELL . " WHERE articles_id = '".(int)$_POST['add_related_article_ID']."'" . $ids; if (!tep_db_query($query)) exit(TEXT_NO_DELETE); } else if (isset($_POST['xsell_id'])) { $id = $_GET['add_related_article_ID']; foreach ($_POST['xsell_id'] as $temp) { $query = "INSERT INTO " . TABLE_ARTICLES_XSELL . " VALUES ('',$id,$temp,1)"; if (!tep_db_query($query)) exit(TEXT_NO_INSERT); } } ?> <tr> <td class="main"><?php echo TEXT_DATABASE_UPDATED; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo sprintf(TEXT_LINK_SORT_PRODUCTS, tep_href_link(FILENAME_ARTICLES_XSELL, '&sort=1&add_related_article_ID=' . (int)$_POST['add_related_article_ID'], 'NONSSL')); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo sprintf(TEXT_LINK_MAIN_PAGE, tep_href_link(FILENAME_ARTICLES_XSELL, '', 'NONSSL')); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php // if ($_POST[xsell_id]) // echo '<a href="' . tep_href_link(FILENAME_ARTICLES_XSELL, 'sort=1&add_related_article_ID=' . $_POST[add_related_article_ID], 'NONSSL') . '">Click here to sort (top to bottom) the added cross sale</a>' . "\n"; } if (isset($_GET['add_related_article_ID']) && ! $_POST && ! isset($_GET['sort'])) { echo tep_draw_form('goto', "articles_xsell.php", '', 'get') . tep_hide_session_id(); echo '<input type="hidden" name="add_related_article_ID" value="'.(int)$_GET['add_related_article_ID'].'" />'; echo SELECT_CATEGORY ." :" . tep_draw_pull_down_menu('cPath', tep_get_category_tree(), $current_category_id, 'onChange="this.form.submit();"'); echo '</form>'; if (isset($_GET['cPath'])) { ?> <table border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <form name="selections" action="<?php tep_href_link(FILENAME_ARTICLES_XSELL, '', 'NONSSL'); ?>" method="post"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent"><input type="checkbox" id="selectall" /></td> <td class="dataTableHeadingContent" nowrap>ID</td> <td class="dataTableHeadingContent"><?php echo HEADING_PRODUCT_NAME; ?></td> </tr> <?php $query = "select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p2c.categories_id='".tep_db_input((int)$_GET['cPath'])."' and pd.products_id = p.products_id and p2c.products_id=p.products_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name "; list ($products_id, $products_name, $products_description, $products_url ) = general_db_conct($query); $num_of_products = sizeof($products_id); $query = "select * from " . TABLE_ARTICLES_XSELL . " where articles_id = '".(int)$_GET['add_related_article_ID']."'"; list ($ID_PR, $products_id_pr, $xsell_id_pr) = general_db_conct($query); $run_update=false; // set to false to insert new entry in the DB for ($i=0; $i < $num_of_products; ++$i) { ?><tr bgcolor="#FFFFFF" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"> <td class="dataTableContent"><input <?php /* this is to see it it is in the DB */ if ($xsell_id_pr) { foreach ($xsell_id_pr as $compare_checked) { if ($products_id[$i]===$compare_checked) { echo "checked"; $run_update=true; } } } ?> size="20" size="20" class="checkbox1" name="xsell_id[]" type="checkbox" value="<?php echo $products_id[$i]; ?>"> </td> <?php echo "<td class=\"dataTableContent\" align=center>".$products_id[$i]."</td>\n" ."<td class=\"dataTableContent\">".$products_name[$i]."</td>\n"; } ?> <tr> <td> </td> <td> </td> <td bgcolor="#CCCCCC"> <?php // list also those products not in current category $myquery = "SELECT ax.xsell_id AS nid FROM " . TABLE_ARTICLES_XSELL . " ax, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c WHERE ax.articles_id='".(int)$_POST['add_related_article_ID']."' AND ax.xsell_id=p2c.products_id AND categories_id!='".tep_db_input((int)$_GET['cPath'])."'"; $myids_query = tep_db_query($myquery); ?> <div style="display:none"> <?php while ($tempid = tep_db_fetch_array($myids_query)) { echo '<input type="checkbox" name="xsell_id[]" value="'.$tempid['nid'].'" checked>'; } ?></div> <input type="hidden" name="run_update" value="<?php echo $run_update; ?>"> <input type="hidden" name="add_related_article_ID" value="<?php echo (int)$_GET['add_related_article_ID']; ?>"> <?php echo tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES_XSELL) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?> </td> </tr> </form> </table> <?php } } // sort routines if (isset($_GET['sort']) && $_GET['sort'] == 1) { // first lets take care of the DB update. $run_once=0; if ($_POST) { foreach ($_POST as $key_a => $value_a) { tep_db_connect(); $query = "UPDATE " . TABLE_ARTICLES_XSELL . " SET sort_order = '".$value_a."' WHERE xsell_id= '$key_a' "; if ($value_a != 'Update') if (!tep_db_query($query)) exit(TEXT_NO_UPDATE); else if ($run_once==0) { ?> <tr> <td class="main"><?php echo TEXT_DATABASE_UPDATED; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo sprintf(TEXT_LINK_MAIN_PAGE, tep_href_link(FILENAME_ARTICLES_XSELL, '', 'NONSSL')); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php $run_once++; } }// end of foreach. } ?> <form method="post" action="<?php tep_href_link(FILENAME_ARTICLES_XSELL, 'sort=1&add_related_article_ID=' . $_POST['add_related_article_ID'], 'NONSSL'); ?>"> <table cellpadding="3" cellspacing="1" bgcolor="#CCCCCC" border="0"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent">ID</td> <td class="dataTableHeadingContent"><?php echo HEADING_PRODUCT_NAME; ?></td> <td class="dataTableHeadingContent"><?php echo HEADING_PRODUCT_ORDER; ?></td> </tr> <?php $query = "select * from " . TABLE_ARTICLES_XSELL . " where articles_id = '".(int)$_GET['add_related_article_ID']."'"; list ($ID_PR, $products_id_pr, $xsell_id_pr, $order_PR) = general_db_conct($query); $ordering_size =sizeof($ID_PR); for ($i=0;$i<$ordering_size;++$i) { $query = "select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = ".$xsell_id_pr[$i].""; list ($products_id, $products_name, $products_description, $products_url) = general_db_conct($query); ?> <tr class="dataTableContentRow" bgcolor="#FFFFFF"> <td class="dataTableContent"><?php echo $products_id[0]; ?></td> <td class="dataTableContent"><?php echo $products_name[0]; ?></td> <td class="dataTableContent" align="center"><select name="<?php echo $products_id[0]; ?>"> <?php for ($y=1;$y<=$ordering_size;++$y) { echo "<option value=\"$y\""; if (!(strcmp($y, "$order_PR[$i]"))) {echo "SELECTED";} echo ">$y</option>"; } ?> </select></td> </tr> <?php } // the end of foreach ?> <tr> <td> </td> <td bgcolor="#CCCCCC"><?php echo tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES_XSELL) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> <td> </td> </tr> </table> </form> <?php }?> </td> </tr> </table> <!-- End of cross sale //--> </td> </tr></table> <script type="text/javascript"> $(document).ready(function() { $('#selectall').click(function(event) { //on click if(this.checked) { // check select status $('.checkbox1').each(function() { //loop through each checkbox this.checked = true; //select all checkboxes with class "checkbox1" }); }else{ $('.checkbox1').each(function() { //loop through each checkbox this.checked = false; //deselect all checkboxes with class "checkbox1" }); } }); });</script> <?php require(DIR_WS_INCLUDES . 'template_bottom.php'); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Script is at the end. Select All Checkbox: line 208 Select All Inputs: line 238 Hope this is useful to someone.
  3. techhouse

    Article Manager v1.0

    Thanks, for the great Articles Manager contribution!
  4. techhouse

    Article Manager v1.0

    Thanks Jack, that totally fixed it. I had too many troubleshooters going (and some in the wrong place). New working function for osCommerce 2.3.4 Boostrap: /* general_db_conct($query) function */ /* calling the function: list ($test_a, $test_b) = general_db_conct($query); */ function general_db_conct($query_1) { // $link = tep_db_connect(); $link = new mysqli(DB_SERVER,DB_SERVER_USERNAME,DB_SERVER_PASSWORD,DB_DATABASE); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } /* Select queries return a resultset */ if ($result_1 = mysqli_query($link, $query_1)) { $num_of_rows = mysqli_num_rows($result_1); $a_to_pass = array(); for ($i=0;$i<$num_of_rows;++$i) { $fields = mysqli_fetch_row($result_1); $a_to_pass[$i]= $fields[$y=0]; $b_to_pass[$i]= $fields[++$y]; $c_to_pass[$i]= $fields[++$y]; $d_to_pass[$i]= $fields[++$y]; $e_to_pass[$i]= $fields[++$y]; $f_to_pass[$i]= $fields[++$y]; $g_to_pass[$i]= $fields[++$y]; $h_to_pass[$i]= $fields[++$y]; $i_to_pass[$i]= $fields[++$y]; $j_to_pass[$i]= $fields[++$y]; $k_to_pass[$i]= $fields[++$y]; $l_to_pass[$i]= $fields[++$y]; $m_to_pass[$i]= $fields[++$y]; $n_to_pass[$i]= $fields[++$y]; $o_to_pass[$i]= $fields[++$y]; } return array($a_to_pass,$b_to_pass,$c_to_pass,$d_to_pass,$e_to_pass,$f_to_pass,$g_to_pass,$h_to_pass,$i_to_pass,$j_to_pass,$k_to_pass,$l_to_pass,$m_to_pass,$n_to_pass,$o_to_pass); /* free result set */ mysqli_free_result($result_1); } }//end of function This may not be the best looking code, but it works. Feel free to improve, as you see fit,
  5. techhouse

    Article Manager v1.0

    I made some changes, and was able to connect to DB and generate Xsell table; but, the code fails after a 7 entries, with the following error: Catchable fatal error: Object of class mysqli_result could not be converted to string in /admin/articles_xsell.php on line 66 /* general_db_conct($query) function */ /* calling the function: list ($test_a, $test_b) = general_db_conct($query); */ function general_db_conct($query_1) { // $link = tep_db_connect(); $link = new mysqli(DB_SERVER,DB_SERVER_USERNAME,DB_SERVER_PASSWORD,DB_DATABASE); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } //$result_1 = mysqli_query($link,$query_1) or die($result_1.$query_1."error 1:".mysql_error()); /* Select queries return a resultset */ if ($result_1 = mysqli_query($link, $query_1)) { printf("Select returned %d rows.\n", mysqli_num_rows($result_1)); $num_of_rows = mysqli_num_rows($result_1) or die($result_1.$query_1."error 2:".mysql_error()); //printf("Select returned %d rows.\n", mysqli_fetch_row($result_1)); $a_to_pass = array(); for ($i=0;$i<$num_of_rows;++$i) { $fields = mysqli_fetch_row($result_1); $a_to_pass[$i]= $fields[$y=0]; $b_to_pass[$i]= $fields[++$y]; $c_to_pass[$i]= $fields[++$y]; $d_to_pass[$i]= $fields[++$y]; $e_to_pass[$i]= $fields[++$y]; $f_to_pass[$i]= $fields[++$y]; $g_to_pass[$i]= $fields[++$y]; $h_to_pass[$i]= $fields[++$y]; $i_to_pass[$i]= $fields[++$y]; $j_to_pass[$i]= $fields[++$y]; $k_to_pass[$i]= $fields[++$y]; $l_to_pass[$i]= $fields[++$y]; $m_to_pass[$i]= $fields[++$y]; $n_to_pass[$i]= $fields[++$y]; $o_to_pass[$i]= $fields[++$y]; } return array($a_to_pass,$b_to_pass,$c_to_pass,$d_to_pass,$e_to_pass,$f_to_pass,$g_to_pass,$h_to_pass,$i_to_pass,$j_to_pass,$k_to_pass,$l_to_pass,$m_to_pass,$n_to_pass,$o_to_pass); /* free result set */ mysqli_free_result($result_1); } }//end of function Any thoughts?
  6. techhouse

    Article Manager v1.0

    Installed Version: osCommerce Online Merchant v2.3.4
  7. techhouse

    Article Manager v1.0

    Hi gang, I am getting a strange error from the admin > Cross-Sell Articles page: "Warning: mysql_fetch_row() expects parameter 1 to be resource, object given in /home/.../admin/articles_xsell.php on line 55" Seems to be related to this section of code, from admin/articles_xsell.php /* general_db_conct($query) function */ /* calling the function: list ($test_a, $test_b) = general_db_conct($query); */ function general_db_conct($query_1) { $result_1 = tep_db_query($query_1) or die($query_1."error 1:".mysql_error()); $num_of_rows = tep_db_num_rows($result_1) or die($result_1."error 2:".mysql_error()); $a_to_pass = array(); for ($i=0;$i<$num_of_rows;++$i) { $fields = mysql_fetch_row($result_1); $a_to_pass[$i]= $fields[$y=0]; $b_to_pass[$i]= $fields[++$y]; $c_to_pass[$i]= $fields[++$y]; $d_to_pass[$i]= $fields[++$y]; $e_to_pass[$i]= $fields[++$y]; $f_to_pass[$i]= $fields[++$y]; $g_to_pass[$i]= $fields[++$y]; $h_to_pass[$i]= $fields[++$y]; $i_to_pass[$i]= $fields[++$y]; $j_to_pass[$i]= $fields[++$y]; $k_to_pass[$i]= $fields[++$y]; $l_to_pass[$i]= $fields[++$y]; $m_to_pass[$i]= $fields[++$y]; $n_to_pass[$i]= $fields[++$y]; $o_to_pass[$i]= $fields[++$y]; } return array($a_to_pass,$b_to_pass,$c_to_pass,$d_to_pass,$e_to_pass,$f_to_pass,$g_to_pass,$h_to_pass,$i_to_pass,$j_to_pass,$k_to_pass,$l_to_pass,$m_to_pass,$n_to_pass,$o_to_pass); }//end of function This worked on my previous 2.2 osCommerce, running an older version of PHP and mySQL. I am running PHP version 5.4.38 and MySQL version 5.5.40-36.; but, I don't see the problem. Any advice?
  8. techhouse

    Quantity Price Breaks

    Yes, I have the same issue. I have updated every other file, but this one has no update information in the install instructions, and has very little in common with the destination product_listing.php. Although, everything seems to function, without it. What does this file do? Does it change the pricing to the "priced from" pricing and fix the "special" prices? Where do these get called? define('TEXT_PRICE_BREAKS', 'From'); define('TEXT_ON_SALE', 'On sale'); getPriceStringShort They don't seem to get used, at all.
  9. Great project! Thanks, for all your hard work. I checked out the demo, and the results are screaming fast. I am downloading, and will start implementing a working version, soon; and, will provide as much feedback as possible. Do you want bugs and feature requests posted, here? Cheers, Rob
  10. Was this problem ever resolved? I used this function for the first time today, and got the same output. Zones are configured (I have 5 setup, one none of them work, when selected as an exclusion option). I get the same error as above.
×