Jump to content
defender39

Wishlist 2.0 Support Thread

Recommended Posts

I am having trouble with the splitPageResults. IF I use the code that Matti pointed out

$wishlist_split = new splitPageResults($wishlist_query_raw, MAX_DISPLAY_WISHLIST_PRODUCTS);

then my results will not paginate.

 

If I use the original code

$wishlist_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_WISHLIST_PRODUCTS, $wishlist_query_raw, $wishlist_numrows);

I get a SQL error that looks like

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 'select * from customers_wishlist WHERE customers_id=11) as tota

select count(select * from customers_wishlist WHERE customers_id=11) as total

[TEP STOP]

 

I have tried to make my way through the splitPageResults function to figure out where the error is coming in, but I am having little luck.

 

Any ideas?

Share this post


Link to post
Share on other sites

try to use both...make a split_page_function2

 

this is what I had to do split_page_function should be for your site and split_page_function2 should be used for wishlist

Share this post


Link to post
Share on other sites
I get a SQL error that looks like

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 'select * from customers_wishlist WHERE customers_id=11) as tota

select count(select * from customers_wishlist WHERE customers_id=11) as total

[TEP STOP]

 

 

Any ideas?

I am having this same problem. Anyone know how to fix it?

Edited by webslingers

Share this post


Link to post
Share on other sites
I get a SQL error that looks like

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 'select * from customers_wishlist WHERE customers_id=11) as tota

select count(select * from customers_wishlist WHERE customers_id=11) as total

[TEP STOP]

 

 

Any ideas?

I am having this same problem. Anyone know how to fix it?

 

 

Use the code I posted for splitPageResults earlier in this thread :blink:

Edited by Johnson

Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

can anyone help with thbis error?

 

Error!

 

Unable to determine the page link!

 

driving me mad - !!

 

thanks

 

mark

 

you can see what i mean if you click my www


Regards

 

Mark A Reynolds

Share this post


Link to post
Share on other sites

DANG! your site is totally broken. I told you to back up your application_top!

 

PM me your ftp if you want me to take a look at it. I hope you do have a backup. I can get it working I am sure. It was hell for me too. I was hoping that it would be easier for others but I see its not. This contrib is a bit touchy to install into application_top and I will say again. BACK UP YOUR FILES

Share this post


Link to post
Share on other sites

Hi,

Just wondering if its possible to have wish-list on category basis .. I don?t want all items of my store to go in wish-list .... Just a particular category items are permitted for wish-list .. Is this possible.

Thanks

Share this post


Link to post
Share on other sites
I got this installed with no errors so far, but when I add something to the wishlist then click on View My Wishlist nothings in it.

Check the </form> tags in product_info.php - there should be two of them - one for the add to cart button, and another for add to wishlist.


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites
try to use both...make a split_page_function2

 

this is what I had to do split_page_function should be for your site and split_page_function2 should be used for wishlist

I get eh same DB error and read through this entire thread which BTW cleared up all the error messages I was getting up until this point.

 

Not being a scripter can you explain what you mean by adding a Split2 routine or document it for us dummies?

 

Thanx!

Share this post


Link to post
Share on other sites

Ok..you have the split_page_results2 in /catalog/includes/classes/split_page_results.php and thats what comes with your OSC. Now if you have MS1 then get MS2 and rip the function from there are add it to your general.php but name it split_page_results2

Or if you have MS2 then go get the MS1 function.

 

It's not too hard...

OK here is what I have done. This is my split_page_functions.php You can use it and you might have to rename the functions for your site.

Rename splitPageResults2 to splitPageResults and vice versa if it doesnt work for you the way I have it. Basically this allows you to have the split page results from ms1 and ms2 contribs.

<?php
/*
 $Id: split_page_results.php,v 1.11 2003/02/13 04:23:23 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

 class splitPageResults {

/*
NOTE: the constructor (also) builds an sql query that counts the total records from $sql_query..
     this value is then saved as $query_num_rows (which does not have to be set before
     creating an instance of this class.
     Please note the function references (&$variable) - please read up on this in the PHP documentation.
*/

/* class constructor */

   function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows) {

     if (empty($current_page_number)) $current_page_number = 1;

     $pos_to = strlen($sql_query);
     $pos_from = strpos($sql_query, ' from', 0);

     $pos_group_by = strpos($sql_query, ' group by', $pos_from);
     if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by;

     $pos_having = strpos($sql_query, ' having', $pos_from);
     if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having;

     $pos_order_by = strpos($sql_query, ' order by', $pos_from);
     if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by;

     $pos_limit = strpos($sql_query, ' limit', $pos_from);
     if (($pos_limit < $pos_to) && ($pos_limit != false)) $pos_to = $pos_limit;

     $pos_procedure = strpos($sql_query, ' procedure', $pos_from);
     if (($pos_procedure < $pos_to) && ($pos_procedure != false)) $pos_to = $pos_procedure;

     $offset = ($max_rows_per_page * ($current_page_number - 1));
     $sql_query .= " limit " . $offset . ", " . $max_rows_per_page;

     $reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, ($pos_to - $pos_from)));
     $reviews_count = tep_db_fetch_array($reviews_count_query);
     $query_num_rows = $reviews_count['total'];
   }

/* class functions */

// display split-page-number-links
   function display_links($query_numrows, $max_rows_per_page, $max_page_links, $current_page_number, $parameters = '') {
     $class = 'class="pageResults"';

     if ( tep_not_null($parameters) && (substr($parameters, -1) != '&') ) $parameters .= '&';

// calculate number of pages needing links 
     $num_pages = intval($query_numrows / $max_rows_per_page);

// $num_pages now contains int of pages needed unless there is a remainder from division 
     if ($query_numrows % $max_rows_per_page) $num_pages++; // has remainder so add one page 

// first button - not displayed on first page
//      if ($current_page_number > 1) echo '<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']),  $parameters . 'page=1') . '" ' . $class . ' title=" ' . PREVNEXT_TITLE_FIRST_PAGE . ' ">' . PREVNEXT_BUTTON_FIRST . '</a> ';

// previous button - not displayed on first page
     if ($current_page_number > 1) echo '<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . 'page=' . ($current_page_number - 1)) . '" ' . $class . ' title=" ' . PREVNEXT_TITLE_PREVIOUS_PAGE . ' "><u>' . PREVNEXT_BUTTON_PREV . '</u></a>  ';

// check if num_pages > $max_page_links
     $cur_window_num = intval($current_page_number / $max_page_links);
     if ($current_page_number % $max_page_links) $cur_window_num++;

     $max_window_num = intval($num_pages / $max_page_links);
     if ($num_pages % $max_page_links) $max_window_num++;

// previous window of pages
     if ($cur_window_num > 1) echo '<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . 'page=' . (($cur_window_num - 1) * $max_page_links)) . '" ' . $class . ' title=" ' . sprintf(PREVNEXT_TITLE_PREV_SET_OF_NO_PAGE, $max_page_links) . ' ">...</a>';

// page nn button
     for ($jump_to_page = 1 + (($cur_window_num - 1) * $max_page_links); ($jump_to_page <= ($cur_window_num * $max_page_links)) && ($jump_to_page <= $num_pages); $jump_to_page++) {
       if ($jump_to_page == $current_page_number) {
         echo ' <b>' . $jump_to_page . '</b> ';
       } else {
         echo ' <a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . 'page=' . $jump_to_page) . '" ' . $class . ' title=" ' . sprintf(PREVNEXT_TITLE_PAGE_NO, $jump_to_page) . ' "><u>' . $jump_to_page . '</u></a> ';
       }
     }

// next window of pages
     if ($cur_window_num < $max_window_num) echo '<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . 'page=' . (($cur_window_num) * $max_page_links + 1)) . '" ' . $class . ' title=" ' . sprintf(PREVNEXT_TITLE_NEXT_SET_OF_NO_PAGE, $max_page_links) . ' ">...</a> ';

// next button
     if (($current_page_number < $num_pages) && ($num_pages != 1)) echo ' <a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . 'page=' . ($current_page_number + 1)) . '" ' . $class . ' title=" ' . PREVNEXT_TITLE_NEXT_PAGE . ' "><u>' . PREVNEXT_BUTTON_NEXT . '</u></a> ';

// last button
//      if (($current_page_number < $num_pages) && ($num_pages != 1)) echo '<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . 'page=' . $num_pages) . '" ' . $class . ' title=" ' . PREVNEXT_TITLE_LAST_PAGE . ' ">' . PREVNEXT_BUTTON_LAST . '</a> ';
   }

// display number of total products found
   function display_count($query_numrows, $max_rows_per_page, $current_page_number, $text_output) {

     $to_num = ($max_rows_per_page * $current_page_number);
     if ($to_num > $query_numrows) $to_num = $query_numrows;
     $from_num = ($max_rows_per_page * ($current_page_number - 1));
     if ($to_num == 0) {
       $from_num = 0;
     } else {
       $from_num++;
     }

     return sprintf($text_output, $from_num, $to_num, $query_numrows);
   }
 }

/*
 $Id: split_page_results.php,v 1.15 2003/06/09 22:35:34 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class splitPageResults2 {
   var $sql_query, $number_of_rows, $current_page_number, $number_of_pages, $number_of_rows_per_page, $page_name;

/* class constructor */
   function splitPageResults2($query, $max_rows, $count_key = '*', $page_holder = 'page') {
     global $HTTP_GET_VARS, $HTTP_POST_VARS;

     $this->sql_query = $query;
     $this->page_name = $page_holder;

     if (isset($HTTP_GET_VARS[$page_holder])) {
       $page = $HTTP_GET_VARS[$page_holder];
     } elseif (isset($HTTP_POST_VARS[$page_holder])) {
       $page = $HTTP_POST_VARS[$page_holder];
     } else {
       $page = '';
     }

     if (empty($page) || !is_numeric($page)) $page = 1;
     $this->current_page_number = $page;

     $this->number_of_rows_per_page = $max_rows;

     $pos_to = strlen($this->sql_query);
     $pos_from = strpos($this->sql_query, ' from', 0);

     $pos_group_by = strpos($this->sql_query, ' group by', $pos_from);
     if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by;

     $pos_having = strpos($this->sql_query, ' having', $pos_from);
     if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having;

     $pos_order_by = strpos($this->sql_query, ' order by', $pos_from);
     if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by;

     if (strpos($this->sql_query, 'distinct') || strpos($this->sql_query, 'group by')) {
       $count_string = 'distinct ' . tep_db_input($count_key);
     } else {
       $count_string = tep_db_input($count_key);
     }

     $count_query = tep_db_query("select count(" . $count_string . ") as total " . substr($this->sql_query, $pos_from, ($pos_to - $pos_from)));
     $count = tep_db_fetch_array($count_query);

     $this->number_of_rows = $count['total'];

     $this->number_of_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page);

     if ($this->current_page_number > $this->number_of_pages) {
       $this->current_page_number = $this->number_of_pages;
     }

     $offset = ($this->number_of_rows_per_page * ($this->current_page_number - 1));

     $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;
   }

/* class functions */

// display split-page-number-links
   function display_links2($max_page_links, $parameters = '') {
     global $PHP_SELF, $request_type;

     $display_links_string = '';

     $class = 'class="pageResults"';

     if (tep_not_null($parameters) && (substr($parameters, -1) != '&')) $parameters .= '&';

// previous button - not displayed on first page
     if ($this->current_page_number > 1) $display_links_string .= '<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . ($this->current_page_number - 1), $request_type) . '" class="pageResults" title=" ' . PREVNEXT_TITLE_PREVIOUS_PAGE . ' "><u>' . PREVNEXT_BUTTON_PREV . '</u></a>  ';

// check if number_of_pages > $max_page_links
     $cur_window_num = intval($this->current_page_number / $max_page_links);
     if ($this->current_page_number % $max_page_links) $cur_window_num++;

     $max_window_num = intval($this->number_of_pages / $max_page_links);
     if ($this->number_of_pages % $max_page_links) $max_window_num++;

// previous window of pages
     if ($cur_window_num > 1) $display_links_string .= '<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . (($cur_window_num - 1) * $max_page_links), $request_type) . '" class="pageResults" title=" ' . sprintf(PREVNEXT_TITLE_PREV_SET_OF_NO_PAGE, $max_page_links) . ' ">...</a>';

// page nn button
     for ($jump_to_page = 1 + (($cur_window_num - 1) * $max_page_links); ($jump_to_page <= ($cur_window_num * $max_page_links)) && ($jump_to_page <= $this->number_of_pages); $jump_to_page++) {
       if ($jump_to_page == $this->current_page_number) {
         $display_links_string .= ' <b>' . $jump_to_page . '</b> ';
       } else {
         $display_links_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . $jump_to_page, $request_type) . '" class="pageResults" title=" ' . sprintf(PREVNEXT_TITLE_PAGE_NO, $jump_to_page) . ' "><u>' . $jump_to_page . '</u></a> ';
       }
     }

// next window of pages
     if ($cur_window_num < $max_window_num) $display_links_string .= '<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . (($cur_window_num) * $max_page_links + 1), $request_type) . '" class="pageResults" title=" ' . sprintf(PREVNEXT_TITLE_NEXT_SET_OF_NO_PAGE, $max_page_links) . ' ">...</a> ';

// next button
     if (($this->current_page_number < $this->number_of_pages) && ($this->number_of_pages != 1)) $display_links_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), $parameters . 'page=' . ($this->current_page_number + 1), $request_type) . '" class="pageResults" title=" ' . PREVNEXT_TITLE_NEXT_PAGE . ' "><u>' . PREVNEXT_BUTTON_NEXT . '</u></a> ';

     return $display_links_string;
   }

// display number of total products found
   function display_count2($text_output) {
     $to_num = ($this->number_of_rows_per_page * $this->current_page_number);
     if ($to_num > $this->number_of_rows) $to_num = $this->number_of_rows;

     $from_num = ($this->number_of_rows_per_page * ($this->current_page_number - 1));

     if ($to_num == 0) {
       $from_num = 0;
     } else {
       $from_num++;
     }

     return sprintf($text_output, $from_num, $to_num, $this->number_of_rows);
   }
 }


?>

Share this post


Link to post
Share on other sites
I got this installed with no errors so far, but when I add something to the wishlist then click on View My Wishlist nothings in it.

Check the </form> tags in product_info.php - there should be two of them - one for the add to cart button, and another for add to wishlist.

This is an issue I ran into and is a bug with the current contri and MS2, but it's fairly easy to fix.

 

I haven't tackled it yet, but I would like the "Add to Wishlist" button to appear to non-loggedin users as well, and then ask them to login, then add whatever item to the wishlist. How hard would this be? I haven't even looked at the code yet to see how it might be done.

Share this post


Link to post
Share on other sites
Use the code I posted for splitPageResults earlier in this thread :blink:

Matti,

If you'll notice in my original post, I mentioned that I had tried it with the code you posted. I still get the error.

 

I'll try using two split_page functions as defender suggested.

Share this post


Link to post
Share on other sites
I got this installed with no errors so far, but when I add something to the wishlist then click on View My Wishlist nothings in it.

Check the </form> tags in product_info.php - there should be two of them - one for the add to cart button, and another for add to wishlist.

 

It needs to be changed to

 

Interesting, I only have one </form> in my product_info and when I put the

</table></form></td>
 
<td align="right" class="main"><?php echo tep_draw_form('wishlist_quantity', tep_href_link(FILENAME_WISHLIST, tep_get_all_get_params(array('action')) . 'action=add_wishlist')); ?> 
          <?php if (tep_session_is_registered('customer_id')) echo tep_draw_hidden_field('products_id', $product_info_values['products_id']) . tep_image_submit('button_wishlist.gif', IMAGE_BUTTON_ADD_WISHLIST); ?></td>

     

then it works great, BUT, then the page looks like this

SNAG-0050.jpg

 

It needs to be changed to

</form>
 
<td align="right" class="main"><?php echo tep_draw_form('wishlist_quantity', tep_href_link(FILENAME_WISHLIST, tep_get_all_get_params(array('action')) . 'action=add_wishlist')); ?> 
          <?php if (tep_session_is_registered('customer_id')) echo tep_draw_hidden_field('products_id', $product_info_values['products_id']) . tep_image_submit('button_wishlist.gif', IMAGE_BUTTON_ADD_WISHLIST); ?></td>
</table></td>


Best Regards

Share this post


Link to post
Share on other sites

Hi,

Just wondering if its possible to have wish-list on category basis .. I don?t want all items of my store to go in wish-list .... Just a particular category items are permitted for wish-list .. Is this possible.

Thanks

Share this post


Link to post
Share on other sites
I get a SQL error that looks like

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 'select * from customers_wishlist WHERE customers_id=11) as tota

select count(select * from customers_wishlist WHERE customers_id=11) as total

[TEP STOP]

 

 

Any ideas?

I am having this same problem. Anyone know how to fix it?

 

 

Use the code I posted for splitPageResults earlier in this thread :blink:

Thank you! That did the trick. The only problem I have now is that the "add to wishlist" button doesnt come up on the product pages. Did I miss something?

 

http://www.premierepremiums.net

 

Thanks for all your help.

Edited by webslingers

Share this post


Link to post
Share on other sites

Ok the split_page_results.php that was posted fixed the rest of the problems :)

 

The location of the button was the next issue but the posted code at least moves the button up just under "Review, Back Add to Cart" Is there anyway to get the "Add to Wish List" button int he same table?

 

Thanx to everyone for the help!

Share this post


Link to post
Share on other sites

Try this to properly format your product_info.php. It works perfectly on my M2 store. Just make sure that you backup your product_info.php first.

 

<!-- Wishlist //-->

<tr>

<td><br><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>

<td align="center" class="main"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></form></td>

<td align="right" class="main"><?php echo tep_draw_form('wishlist_quantity', tep_href_link(FILENAME_WISHLIST, tep_get_all_get_params(array('action')) . 'action=add_wishlist')); ?>

<?php if (tep_session_is_registered('customer_id')) echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_wishlist.gif', IMAGE_BUTTON_ADD_WISHLIST); ?>

</form></td>

</tr>

</table></td>

</tr>

<tr>

<td><br>

<?php

if ( (USE_CACHE == 'true') && !defined('SID')) {

echo tep_cache_also_purchased(3600);

} else {

include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);

}

}

?>

</td>

</tr>

</table></td>

<!-- Wishlist eof //-->

Share this post


Link to post
Share on other sites

I have a question Jesse. Has the email problem been corrected yet. When I tried to use it, it would send the email, listing the same product about 6 times. I believe Matti had mentioned this awhile back. And also where would you put the button or link for the Wishlist email?

 

Thanks in advance

Share this post


Link to post
Share on other sites

The post for prodcut_info.php neted me a second line of buttons and left out the "Back" button. I think I remember adding that a a modification. Maybe if you could just give me the code for the WishList button and tell me where it should be inserted in product_info.php that would be better?

 

Thanx again :)

Share this post


Link to post
Share on other sites

Hi Steven,

 

I don't have a "Back" button on my product_info.php page. This is what I have:

 

"Product Reviews" "Add to Shopping Cart" "Add to Wishlist"

 

These 3 buttons are all on one line.

Share this post


Link to post
Share on other sites
The post for prodcut_info.php neted me a second line of buttons and left out the "Back" button. I think I remember adding that a a modification. Maybe if you could just give me the code for the WishList button and tell me where it should be inserted in product_info.php that would be better?

 

Thanx again :)

Same here, this mod according to the readme.txt file was written for MS1, I'm using MS2, I have tried the code in almost every position in the product_info.php but it will not add the products to the wishlist unless the code is past the </form> tag, besides this leaves space for more future buttons, if needed, at least it works now.

 

Johnson:

 

You have some nice mods, but your documentation on installing leave nothing to be desired, I guess you don't realize that some of us are heavily modded to start with and searching thru countless files for coding is useless thus making your mods useless for me.

 

I need the changes documented in the readme.txt or install.txt file in order to use them.


Best Regards

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×