Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Wishlist 2.0 Support Thread


defender39

Recommended Posts

When someone uses the form "buy now" then if they have the product in there wishlist, it will remain there as that was the code to delete it out.  I don't really know why that code would cause you any problems...  But its just a small thing as most likely if people use there wishlist they will buy from that and not the product listing pages.

 

Dennis

 

Yeh that was what I deduced the code was supposed to do but for some reason, for me and apparently a lot of others it has just been a trouble some piece of code.

 

At the end of the day I think it may be just as good a thing to leave their (the clinets) wishlist as they want and let them do with it as they wish (a bit of a unintentional pun), rather than trying to do everything for them.

Link to comment
Share on other sites

I'ev installed this contribution and its great but one small problem. At the wish list, when they click the "Continue" button, they're back to the wishlist page. I think the Continue should take them back to the catalog or where they came from

 

-Abbas

Link to comment
Share on other sites

For All those people that were having the problem of the products not being sent from the Wishlist, "Tell A Friend" option, I found the answer. YIPEE :D

 

Also if you want the links to show up in the email instead of just plain text, be sure to turn ON (TRUE) in the Admin, Configuration, Email options, "Use MIME HTML When Sending Emails".

 

Around line 117. Do the below at it will work with or without having to put in a message.

//      if (tep_not_null($HTTP_POST_VARS['yourmessage'])) {

        $email_body .= $wishliststring . "\n\n" . $HTTP_POST_VARS['yourmessage'] . "\n\n";

//      }

 

I have also tidied up some of the other coding. So for simplicity, I'm posting the whole catalog/wishlist_email.php file below. DON'T Forget, Backup first. Now just copy and paste the below and all should be good. This is based on the latest version of Wishlist file name "Wish List v2.3 MS2.2.zip. Version 2.3.1, dated the 6th Feb 2005.

<?php

/*

$Id: wishlist.php,v 2.0  2003/11/22 Jesse Labrocca

 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

 

  Copyright © 2003 osCommerce

 

  Released under the GNU General Public License

*/

 

  require('includes/application_top.php');

 

if (tep_session_is_registered('customer_id')) {

    $account = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");

    $account_values = tep_db_fetch_array($account);

  } elseif (ALLOW_GUEST_TO_TELL_A_FRIEND == 'false') {

    $navigation -> set_snapshot();

    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

  }

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_WISHLIST_SEND);

 

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_WISHLIST_SEND, '', 'NONSSL'));

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

<?

  $wishliststring = FORM_FIELD_TEXT_AREA;

 

  $wishlist_query_raw = "select tab2.products_id, tab1.products_name from " . TABLE_WISHLIST . " as tab2, " . TABLE_PRODUCTS_DESCRIPTION . " as tab1 where tab2.customers_id='" . (int)$customer_id . "' and tab1.products_id = tab2.products_id and tab1.language_id = '" . (int)$languages_id . "' order by products_name";

 

  $wishlist_query = tep_db_query($wishlist_query_raw);

while ($resultarray=mysql_fetch_row($wishlist_query)) {

$wishliststring .=""."<li><a href=\"".HTTP_SERVER . DIR_WS_CATALOG ."product_info.php?products_id=".$resultarray[0] ."\">".$resultarray[1]."</a></li>"."";

}

?>

<!-- body //-->

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

  <tr>

    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

    </table></td>

<!-- body_text //-->

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

 

 

      <tr>

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

          <tr>

            <td class="pageHeading"><?php echo sprintf(HEADING_TITLE, $product_info['products_name']); ?></td>

            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', sprintf(HEADING_TITLE, $product_info['products_name']), HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

          </tr>

        </table></td>

      </tr>

      <tr>

        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

      </tr>

<?php

    $error = false;

 

    if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && !tep_validate_email(trim($HTTP_POST_VARS['friendemail']))) {

      $friendemail_error = true;

      $error = true;

    } else {

      $friendemail_error = false;

    }

 

    if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && empty($HTTP_POST_VARS['friendname'])) {

      $friendname_error = true;

      $error = true;

    } else {

      $friendname_error = false;

    }

 

    if (tep_session_is_registered('customer_id')) {

      $from_name = $account_values['customers_firstname'] . ' ' . $account_values['customers_lastname'];

      $from_email_address = $account_values['customers_email_address'];

    } else {

      $from_name = $HTTP_POST_VARS['yourname'];

      $from_email_address = $HTTP_POST_VARS['from'];

    }

 

    if (!tep_session_is_registered('customer_id')) {

      if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && !tep_validate_email(trim($from_email_address))) {

        $fromemail_error = true;

        $error = true;

      } else {

        $fromemail_error = false;

      }

    }

 

    if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && empty($from_name)) {

      $fromname_error = true;

      $error = true;

    } else {

      $fromname_error = false;

    }

 

    if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && ($error == false)) {

      $email_subject = sprintf(TEXT_EMAIL_SUBJECT, $from_name, STORE_NAME);

      $email_body = sprintf(TEXT_EMAIL_INTRO, $HTTP_POST_VARS['friendname'], $from_name, $HTTP_POST_VARS['products_name'], STORE_NAME) . "\n\n";

 

//      if (tep_not_null($HTTP_POST_VARS['yourmessage'])) {

        $email_body .= $wishliststring . "\n\n" . $HTTP_POST_VARS['yourmessage'] . "\n\n";

//      }

 

      $email_body .= sprintf(TEXT_EMAIL_SIGNATURE, STORE_NAME . "\n"). "<A HREF=\"". HTTP_SERVER . DIR_WS_CATALOG ."\"><b><i>".STORE_NAME."</i></b></A> "."\n";

 

                    "\n\n" . $mywishlist .= $wishlist_query_array[1] ."\n";

 

 

      tep_mail($HTTP_POST_VARS['friendname'], $HTTP_POST_VARS['friendemail'], $email_subject, stripslashes($email_body), '', $from_email_address);

?>

      <tr>

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

          <tr>

            <td class="main"><?php echo sprintf(TEXT_EMAIL_SUCCESSFUL_SENT, $HTTP_POST_VARS['friendemail']); ?></td>

          </tr>

        </table></td>

      </tr>

      <tr>

        <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_WISHLIST) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

      </tr>

<?php

    } else {

      if (tep_session_is_registered('customer_id')) {

        $your_name_prompt = $account_values['customers_firstname'] . ' ' . $account_values['customers_lastname'];

        $your_email_address_prompt = $account_values['customers_email_address'];

      } else {

        $your_name_prompt = tep_draw_input_field('yourname', (($fromname_error == true) ? $HTTP_POST_VARS['yourname'] : $HTTP_GET_VARS['yourname']));

        if ($fromname_error == true) $your_name_prompt .= ' ' . TEXT_REQUIRED;

        $your_email_address_prompt = tep_draw_input_field('from', (($fromemail_error == true) ? $HTTP_POST_VARS['from'] : $HTTP_GET_VARS['from']));

        if ($fromemail_error == true) $your_email_address_prompt .= ENTRY_EMAIL_ADDRESS_CHECK_ERROR;

      }

?>

      <tr>

        <td><?php echo tep_draw_form('email_friend', tep_href_link(FILENAME_WISHLIST_SEND, 'action=process&products_id=' . $HTTP_GET_VARS['products_id'])) . tep_draw_hidden_field('products_name', $product_info['products_name']); ?><table border="0" width="100%" cellspacing="0" cellpadding="2">

          <tr>

            <td class="formAreaTitle"><?php echo FORM_TITLE_CUSTOMER_DETAILS; ?></td>

          </tr>

          <tr>

            <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">

              <tr>

                <td class="main"><table border="0" cellspacing="0" cellpadding="2">

                  <tr>

                    <td class="main"><?php echo FORM_FIELD_CUSTOMER_NAME; ?></td>

                    <td class="main"><?php echo $your_name_prompt; ?></td>

                  </tr>

                  <tr>

                    <td class="main"><?php echo FORM_FIELD_CUSTOMER_EMAIL; ?></td>

                    <td class="main"><?php echo $your_email_address_prompt; ?></td>

                  </tr>

                </table></td>

              </tr>

            </table></td>

          </tr>

          <tr>

            <td class="formAreaTitle"><br><?php echo FORM_TITLE_FRIEND_DETAILS; ?></td>

          </tr>

          <tr>

            <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">

              <tr>

                <td class="main"><table border="0" cellspacing="0" cellpadding="2">

                  <tr>

                    <td class="main"><?php echo FORM_FIELD_FRIEND_NAME; ?></td>

                    <td class="main"><?php echo tep_draw_input_field('friendname', (($friendname_error == true) ? $HTTP_POST_VARS['friendname'] : $HTTP_GET_VARS['friendname'])); if ($friendname_error == true) echo ' ' . TEXT_REQUIRED;?></td>

                  </tr>

                  <tr>

                    <td class="main"><?php echo FORM_FIELD_FRIEND_EMAIL; ?></td>

                    <td class="main"><?php echo tep_draw_input_field('friendemail', (($friendemail_error == true) ? $HTTP_POST_VARS['friendemail'] : $HTTP_GET_VARS['send_to'])); if ($friendemail_error == true) echo ENTRY_EMAIL_ADDRESS_CHECK_ERROR; ?></td>

                  </tr>

                </table></td>

              </tr>

            </table></td>

          </tr>

          <tr>

            <td class="formAreaTitle"><br><?php echo FORM_TITLE_FRIEND_MESSAGE; ?></td>

          </tr>

          <tr>

            <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">

              <tr>

                <td><textarea name="yourmessage" cols=40 rows=4></textarea></td>

              </tr>

            </table></td>

          </tr>

          <tr>

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

              <tr>

                <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_WISHLIST) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

                <td align="right" class="main"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

              </tr>

            </table></td>

          </tr>

        </table></form></td>

      </tr>

<?php

    }

 

?>

    </table></form></td>

<!-- body_text_eof //-->

    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

    </table></td>

  </tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

  • 2 weeks later...

OK my head is fried...

 

I have the contribution working apart from 1 thing. For some reason if my product is out of stock it will not add to wish list.

 

I click on wishlist and it just goes to the wishlist screen saying "No products are in your Wishlist"

 

I have followed the instructions to the letter and it works fine if i have stock. But this kind of defeats the object for what i want to use if for..

 

 

Top contribution by the way.... Please hep me get it to work...

 

If you need snippets of code then i can send them to you....

Link to comment
Share on other sites

OK my head is fried...

 

I have the contribution working apart from 1 thing. For some reason if my product is out of stock it will not add to wish list.

 

I click on wishlist and it just goes to the wishlist screen saying "No products are in your Wishlist"

 

I have followed the instructions to the letter and it works fine if i have stock. But this kind of defeats the object for what i want to use if for..

Top contribution by the way.... Please hep me get it to work...

 

If you need snippets of code then i can send them to you....

 

 

Ok i have found where it is going wrong.... I have some code in products_info.php that basically says if the product is out of stock then do not display ADD TO CART button but display OUT OF STOCK image (no action)... Here is the code..

 

</td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

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

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<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>

<!-- Begin Wishlist Code -->

<td align="center" class="main"><?php echo tep_draw_hidden_field('wishlist_action', 'add_wishlist') . tep_image_submit('button_wishlist.gif', IMAGE_BUTTON_ADD_WISHLIST, 'onClick="document.cart_quantity.action=\''. tep_href_link(FILENAME_WISHLIST) . '\';document.cart_quantity.submit();"'. ' action=add_wishlist'); ?>

<!-- End Wishlist Code -->

<?php if ($product_info['products_quantity'] > 0 ) { ?>

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

<?php } else { ?>

<td class="main" align="right"><?php echo tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK) ?><td>

<?php } ?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

 

Does anybody havea workaround as the out of stock image is vital..

The wishlist only seems to work if the add to cart button is there...

Link to comment
Share on other sites

See this line here within the button of add to cart?

 

tep_draw_hidden_field('products_id', $product_info['products_id']) .

 

Include that within your button of your wishlist code. The problem your facing is the product ID is not being included when you press the wishlist button, therefore it has no idea what to put in the wishlist. Does that make sense?

Link to comment
Share on other sites

Dennis,

Because I think you're the expert of this contribution; can you tell me how to hide the wishlistbox if it's empty? :huh:

I need such an option but can't get the job done by myself :(

TIA

Edited by osCshop
Link to comment
Share on other sites

if (tep_session_is_registered('customer_id')) {  //IF USER IS LOGGED IN, START WISHLIST BOX

 $wishlist_query_raw = "select * from " . TABLE_WISHLIST . " where customers_id = '" . $customer_id . "' order by products_name";
 $wishlist_query = tep_db_query($wishlist_split->sql_query);

   if (tep_db_num_rows($wishlist_query)) {  //GET ITEMS FROM WISHLIST, DISPLAY THE WISHLIST IF IT HAS ANY IN IT
      //SHOW WISHLIST
      //CODE FOR WISHLIST BOX
   } else {
      //SHOW NOTHING
   }
}
//IF USER IS NOT LOGGED IN, THEY WILL NOT SEE THIS BOX

 

Now some of this code should be in your box. I do not use boxes so I don't know what it is. This should give you the idea on what to do.

Link to comment
Share on other sites

Thanks for your reply Dennis!

 

Tryed a few things but no succes.

I use STS, this is a part of my column_left.php

  if ($cart->count_contents() > 0) { require(DIR_WS_BOXES . 'shopping_cart.php'); }

 // STS: ADD
 $sts_block_name = 'cartbox';
 require(STS_RESTART_CAPTURE);
 // STS: EOADD
 
 // Wish List 2.3 Start
 if (tep_session_is_registered('customer_id')) include(DIR_WS_BOXES . 'wishlist.php');
 
 // STS: ADD
 $sts_block_name = 'wishlistbox';
 require(STS_RESTART_CAPTURE);
 // STS: EOADD  
 // Wish List 2.3 End

Can we deactivate wishlist in column_left.php if wishlist is empty?

Link to comment
Share on other sites

  // Wish List 2.3 Start
if (tep_session_is_registered('customer_id')) include(DIR_WS_BOXES . 'wishlist.php');

 

That code is fine, basically says if the user is logged in, include the wishlist box.

 

Now go to includes/boxes/wishlist.php

 

You should see a lot of the code i posted above in there. Such as the query info. Since the

 

if (tep_session_is_registered('customer_id'))

 

is already there in your column.php, then you do not need to add that into the wishlist.php. Lines 12-15 is the query information right? So you dont need to add that either as its already there. Now after line 15 add:

 

if (tep_db_num_rows($wishlist_query)) {

 

It should now look something like this

 

  // $wishlist_query = tep_db_query("select * from " . TABLE_WISHLIST . " WHERE customers_id=$customer_id");
 $wishlist_query_raw = "select * from " . TABLE_WISHLIST . " WHERE customers_id = $customer_id order by products_name";
 $wishlist_query = tep_db_query($wishlist_query_raw);

if (tep_db_num_rows($wishlist_query)) {

 

Now go all the way to the bottom of wishlist.php. After this:

 

            </td>
         </tr>

 

Add this code after:

 

<?php
} else { //Show nothing }
?>

 

It should look like this

 

            </td>
         </tr>
<?php
} else { //Show nothing }
?>
<!-- wishlist_eof //-->

 

 

That's it. Let me know if you have any problems.

 

Dennis

Edited by dblake
Link to comment
Share on other sites

i havent read all the way thru this, just want to know, if this can be used as a 'gift registry', where someone creates the wishlist, it gets sent around to their friends, who in turn come back to the site and purchase a gift frm the wish list, any easy way of removing the item from the wishlist?

Link to comment
Share on other sites

Dennis,

A new error, wishlist works except when remove the last item at the wishlist it gives:

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 '-6, 6' at line 1

 

select * from customers_wishlist where customers_id = '2' order by products_name limit -6, 6

 

[TEP STOP]

If I use the browser backbutton I see the wishlist box is gone so whe're working in the right direction...

Yesterday I also installed "Extra Product Fields" but I doubt if it has something to do with that(?)

Replacing the boxes/wishlist.php for the original doesn't solve it... (verry strange)

Before the modifications it all worked.

Link to comment
Share on other sites

i havent read all the way thru this, just want to know, if this can be used as a 'gift registry', where someone creates the wishlist, it gets sent around to their friends, who in turn come back to the site and purchase a gift frm the wish list, any easy way of removing the item from the wishlist?

 

Yea it could be done, you would just need to make the wishlist public. I would then assign some hash number to it, to keep people from guessing the right gift registry page as it will all be public.

 

So the url would be something like this, www.yoursite.com/gift_registry.php?cID=22&hash=04580kfv9vnjfr01vnjf0293

 

You get the idea. Then you could add in the delete from the wishlist table when they push add to cart. I don't like that idea too much as they may end up not purchasing this item and then, it has been removed from the wishlist table, but nvr was bought. So some suggestions for you;

 

1st way:

 

Register a session variable when they push add to cart from the wishlist page. The variable could equal the customer ID of the wishlist and then upon payment, it will recheck to see if that variable is set, then go in and query the wishlist table where the cID = the session variable and product ID = w/e the products are in your basket when you paid. Loop it, make sure you get all the items, and delete them from the wishlist, so there not purchased twice.

 

2nd way: (better way)

Register the session variable with the wishlist ID.

Make another table so when the user adds the wishlist items to the cart, it adds them to a new table as well. Then upon checkout, if the variable is set, bump the two tables together, and clear the appropriate items. That way a user can buy things for themselves and it not get confused with the items they purchased from the wishlist.

 

But thats some ideas for ya, so yes I think it would work rather beautifully ;)

 

-Dennis

Edited by dblake
Link to comment
Share on other sites

Dennis,

A new error, wishlist works except when remove the last item at the wishlist it gives:

 

If I use the browser backbutton I see the wishlist box is gone so whe're working in the right direction...

Yesterday I also installed "Extra Product Fields" but I doubt if it has something to do with that(?)

Replacing the boxes/wishlist.php for the original doesn't solve it... (verry strange)

Before the modifications it all worked.

 

So if you replace the original boxes/wishlist.php page back in without any modifications, it still gives you that error? What page is that error on? The catalog/wishlist.php?

Link to comment
Share on other sites

More info about the error:

Error is only when the last item is deleted or moved to chopping cart...

If I login at my account while the wishlist is empty the box isn't there (that's good) adding items is OK and moving items to the shopping cart is no problem except with the last item...

Link to comment
Share on other sites

Its almost like the page is refreshing before it has time to get the item taken out of the table, or something...

 

this is the code its looking at

  $wishlist_query_raw = "select * from " . TABLE_WISHLIST . " where customers_id = '" . $customer_id . "' order by products_name";
// $wishlist_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_WISHLIST_PRODUCTS, $wishlist_query_raw, $wishlist_numrows);
 $wishlist_split = new splitPageResults($wishlist_query_raw, MAX_DISPLAY_WISHLIST_PRODUCTS);

 

What is your MAX_DISPLAY_WISHLIST_PRODUCTS set at in your configuration? I wonder how this would act on a live server instead of from your home pc...?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...