Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Wishlist 3.0 Support Thread


dblake

Recommended Posts

<?php
/*
 $Id: wishlist.php,v 3.0  2005/04/20 Dennis Blake
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_WISHLIST);

if(!isset($_GET['public_id'])) {
  tep_redirect(tep_href_link(FILENAME_DEFAULT));
}

 $public_id = $_GET['public_id'];

/*******************************************************************
****************** QUERY CUSTOMER INFO FROM ID *********************
*******************************************************************/

	$customer_query = tep_db_query("select customers_firstname from " . TABLE_CUSTOMERS . " where customers_id = '" . $public_id . "'");
$customer = tep_db_fetch_array($customer_query);

/*******************************************************************
****************** ADD PRODUCT TO SHOPPING CART ********************
*******************************************************************/

 if (isset($HTTP_POST_VARS['add_wishprod'])) {
if(isset($HTTP_POST_VARS['add_prod_x'])) {
	foreach ($HTTP_POST_VARS['add_wishprod'] as $value) {
		$product_id = tep_get_prid($value);
		$cart->add_cart($product_id, $cart->get_quantity(tep_get_uprid($product_id, $HTTP_POST_VARS['id'][$value]))+1, $HTTP_POST_VARS['id'][$value]); 
	}
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
}
 }


$breadcrumb->add(NAVBAR_TITLE_WISHLIST, tep_href_link(FILENAME_WISHLIST, '', 'SSL'));
?>
<!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 (getenv('HTTPS') == 'on' ? 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 //-->

<!-- 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"><?php echo tep_draw_form('wishlist_form', tep_href_link(FILENAME_WISHLIST_PUBLIC)); ?>
  <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 $customer['customers_firstname'] .  HEADING_TITLE2; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_wishlist.gif', HEADING_TITLE, 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
 if ($messageStack->size('wishlist') > 0) {
?>
  <tr>
	<td><?php echo $messageStack->output('wishlist'); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }

/*******************************************************************
****** QUERY THE DATABASE FOR THE CUSTOMERS WISHLIST PRODUCTS ******
*******************************************************************/

 $wishlist_query_raw = "select * from " . TABLE_WISHLIST . " where customers_id = '" . $public_id . "'";
 $wishlist_split = new splitPageResults($wishlist_query_raw, MAX_DISPLAY_WISHLIST_PRODUCTS);
 $wishlist_query = tep_db_query($wishlist_split->sql_query);

?>
<!-- customer_wishlist //-->
<?php

 if (tep_db_num_rows($wishlist_query)) {

if ($wishlist_split > 0 && (PREV_NEXT_BAR_LOCATION == '1' || PREV_NEXT_BAR_LOCATION == '3')) {
?>
  <tr>
	<td>
	<table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="smallText"><?php echo $wishlist_split->display_count(TEXT_DISPLAY_NUMBER_OF_WISHLIST); ?></td>
		<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $wishlist_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
	  </tr>
	</table>
	</td>
  </tr>

<?php
 }
?>
  <tr>
	<td>
			<table border="0" width="100%" cellspacing="0" cellpadding="3" class="productListing">
			  <tr>
					<td class="productListing-heading"><?php echo BOX_TEXT_IMAGE; ?></td>
					<td class="productListing-heading"><?php echo BOX_TEXT_PRODUCT; ?></td>
					<td class="productListing-heading"><?php echo BOX_TEXT_PRICE; ?></td>
					<td class="productListing-heading" align="center"><?php echo BOX_TEXT_SELECT; ?></td>
			  </tr>
<?php 

/*******************************************************************
***** LOOP THROUGH EACH PRODUCT ID TO DISPLAY IN THE WISHLIST ******
*******************************************************************/
$i = 0;
while ($wishlist = tep_db_fetch_array($wishlist_query)) {
$wishlist_id = tep_get_prid($wishlist['products_id']);

$products_query = tep_db_query("select pd.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_status, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.products_id = '" . $wishlist_id . "' and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' order by products_name");
$products = tep_db_fetch_array($products_query);

  if (($i/2) == floor($i/2)) {
	$class = "productListing-even";
  } else {
	$class = "productListing-odd";
  }

?>
			  <tr class="<?php echo $class; ?>">
				<td valign="top" class="productListing-data" align="left"><a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wishlist['products_id'], 'NONSSL'); ?>"><?php echo tep_image(DIR_WS_IMAGES . $products['products_image'], $products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); ?></a></td>
				<td valign="top" class="productListing-data" align="left" class="main"><b><a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wishlist['products_id'], 'NONSSL'); ?>"><?php echo $products['products_name']; ?></a></b>
<?php

/*******************************************************************
******** THIS IS THE WISHLIST CODE FOR PRODUCT ATTRIBUTES  *********
*******************************************************************/

			  $attributes_addon_price = 0;

			  // Now get and populate product attributes
				$wishlist_products_attributes_query = tep_db_query("select products_options_id as po, products_options_value_id as pov from " . TABLE_WISHLIST_ATTRIBUTES . " where customers_id='" . $public_id . "' and products_id = '" . $wishlist['products_id'] . "'");
				while ($wishlist_products_attributes = tep_db_fetch_array($wishlist_products_attributes_query)) {
				  // We now populate $id[] hidden form field with product attributes
				  echo tep_draw_hidden_field('id['.$wishlist['products_id'].']['.$wishlist_products_attributes['po'].']', $wishlist_products_attributes['pov']);
				  // And Output the appropriate attribute name
				  $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
								  from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
								  where pa.products_id = '" . $wishlist_id . "'
								   and pa.options_id = '" . $wishlist_products_attributes['po'] . "'
								   and pa.options_id = popt.products_options_id
								   and pa.options_values_id = '" . $wishlist_products_attributes['pov'] . "'
								   and pa.options_values_id = poval.products_options_values_id
								   and popt.language_id = '" . $languages_id . "'
								   and poval.language_id = '" . $languages_id . "'");
				   $attributes_values = tep_db_fetch_array($attributes);
				   if ($attributes_values['price_prefix'] == '+')
					 { $attributes_addon_price += $attributes_values['options_values_price']; }
				   else if ($attributes_values['price_prefix'] == '-')
					 { $attributes_addon_price -= $attributes_values['options_values_price']; }
				   echo '<br /><small><i> ' . $attributes_values['products_options_name'] . ': ' . $attributes_values['products_options_values_name'] . '</i></small>';
				} // end while attributes for product

				if (tep_not_null($products['specials_new_products_price'])) {
				   $products_price = '<s>' . $currencies->display_price($products['products_price']+$attributes_addon_price, tep_get_tax_rate($products['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($products['specials_new_products_price']+$attributes_addon_price, tep_get_tax_rate($products['products_tax_class_id'])) . '</span>';
				} else {
				   $products_price = $currencies->display_price($products['products_price']+$attributes_addon_price, tep_get_tax_rate($products['products_tax_class_id']));
				}

/*******************************************************************
******* CHECK TO SEE IF PRODUCT HAS BEEN ADDED TO THEIR CART *******
*******************************************************************/

	if($cart->in_cart($wishlist[products_id])) {
		echo '<br /><font color="#FF0000"><b>' . TEXT_ITEM_IN_CART . '</b></font>';
	}

/*******************************************************************
********** CHECK TO SEE IF PRODUCT IS NO LONGER AVAILABLE **********
*******************************************************************/

		if($products['products_status'] == 0) {
  			echo '<br /><font color="#FF0000"><b>' . TEXT_ITEM_NOT_AVAILABLE . '</b></font>';
	  }

	$i++;
?>
				</td>
				<td valign="top" class="productListing-data"><?php echo $products_price; ?></td>
				<td valign="top" class="productListing-data" align="center">
<?php 

/*******************************************************************
* PREVENT THE ITEM FROM BEING ADDED TO CART IF NO LONGER AVAILABLE *
*******************************************************************/

		if($products['products_status'] != 0) {
			echo tep_draw_checkbox_field('add_wishprod[]',$wishlist[products_id]);
		}
?>					</td>
			  </tr>

<?php
}
?>
			</table>
	</td>
  </tr>
  <tr>
	<td align="right"><br /><?php echo tep_image_submit('button_in_cart.gif', 'Add to Cart', 'name="add_prod" value="add_prod"'); ?></td>
	  </tr>




<?php
 if ($wishlist_split > 0 && (PREV_NEXT_BAR_LOCATION == '2' || PREV_NEXT_BAR_LOCATION == '3')) {
?>
  <tr>
	<td>
	<table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="smallText"><?php echo $wishlist_split->display_count(TEXT_DISPLAY_NUMBER_OF_WISHLIST); ?></td>
		<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $wishlist_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
	  </tr>
	</table>
	</td>
  </tr>

<?php
}
?>
</table></form>

<?
} else { // Nothing in the customers wishlist

?>
 <tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="main"><?php echo BOX_TEXT_NO_ITEMS;?></td>
	  </tr>
	</table>
	</td>
  </tr>
</table>
</td>
 </tr>
</table>
</form>
<?php
}
?>
<!-- customer_wishlist_eof //-->


<!-- 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'); ?>

People dont change, people realize.

Link to comment
Share on other sites

<?php echo tep_draw_form('wishlist_form', tep_href_link(FILENAME_WISHLIST_PUBLIC)); ?>

 

to this

 

<?php echo tep_draw_form('wishlist_form', tep_href_link(FILENAME_WISHLIST_PUBLIC, $public_id)); ?>

Link to comment
Share on other sites

<?php echo tep_draw_form('wishlist_form', tep_href_link(FILENAME_WISHLIST_PUBLIC)); ?>

 

to this

 

<?php echo tep_draw_form('wishlist_form', tep_href_link(FILENAME_WISHLIST_PUBLIC, $public_id)); ?>

 

Nope same behaivior. Click the Add to Cart button > redirect to index.php > and nothing in cart. And I also fixed the extra <form> thing. Indeed I had an extra unclosed form in my header, good you noticed :).

 

http://www.mindphantom.com/shop/wishlist_p...php?public_id=3

Edited by Voland

People dont change, people realize.

Link to comment
Share on other sites

sorry

 

<?php echo tep_draw_form('wishlist_form', tep_href_link(FILENAME_WISHLIST_PUBLIC, 'public_id='.$public_id)); ?>

 

AH! Beautiful! Works liek a charm. Thank you!

 

Can you explain mildly what the problem was? Is it native to my site or will all the people with 3.5d experience this?

People dont change, people realize.

Link to comment
Share on other sites

No everyone should have this problem.

 

Good to know lol. I dont feel all alone. Should I upload this fix in the Contributions section? Or will you do it on your next update? :)

 

Onece again Thanks so much.

Edited by Voland

People dont change, people realize.

Link to comment
Share on other sites

Hey dennis,

great contribution, i think this is gonna be what makes my site(as opposed to break). I have just installed it and everything is working ok except for two things:

1/ everytime i view a product it says(in the osC green banner text at the top) "product has been successfully added to wishlist" though it isn't and i never click "add to wishlist" either; this is my main problem

2/ on a catagory list (say games) there is no add to wishlist button like the add to cart; i don't know if this is a missing feature or an error on my part

Please Help!

Nick

Menou and unome

Link to comment
Share on other sites

after about 2 days of trying. i finally figured it out. so for thoughs who have and will have the same problem - here goes:

 

1/ the error is caused by commenting Step 3 of the installation in catalog/product_info.php. like so:

//DISPLAY PRODUCT WAS ADDED TO WISHLIST IF WISHLIST REDIRECT IS ENABLED if(tep_session_is_registered('wishlist_id')) { ?> <tr> <td class="messageStackSuccess"><?php echo PRODUCT_ADDED_TO_WISHLIST; ?></td> </tr> <?php tep_session_unregister('wishlist_id'); }

 

2/ the above error results in a parse error and the only way to have received the green header error is if you corrected this parse error by deleting a } towards the end of your product_info.php file like the parse error suggests meaning you'll have the following code in your file:

<?php

if ((USE_CACHE == 'true') && empty($SID)) {

echo tep_cache_also_purchased(3600);

} else {

include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);

}

?>

 

3/ correct error 1 by unquoting(press return) at if(tep_.....

 

4/ this results in another parse error which can be solved by adding the extra } that you deleted like so:

<?php

if ((USE_CACHE == 'true') && empty($SID)) {

echo tep_cache_also_purchased(3600);

} else {

include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);

}

}

?>

took me 4 hours of crying through syntax in notepad to figure that out :'(

 

hope this helps those who have the same problem

pm me only if you have the same problem but never understood what i said above and i'll walk you through it as soon as i have time

 

Nick

Menou and unome

Link to comment
Share on other sites

Yea umm what are you talking about. There should be no adding } and so on. If you followed the directions, you shouldn't have any problems

I didn't follow the directions per se. Here goes:

If you copy the install instructions directly into your file you end up commenting the code due to no <p> in the install instructions. If you comment the 1st code snippet for step 3 "catalog/product_info.php" you end up getting a parse error saying that line two hundred and something contains a parse error. If you go to this line, there is only a } there. If you delete that, then parse error is gone and wishlist is working perfectly, except for one thing. There is a green "asses to wishlist" confirmation banner every time you view a product. You know the one. Only it never adds anything to the wishlist and you never asked it to in the first place.

 

So uncommenting the code produces a parse error pointing you in the completely wrong direction when all you have to do i re enter the } that you deleted.

 

Try It

Nick

Menou and unome

Link to comment
Share on other sites

could someone please tell me how to include this wishlist as a sts variable for stsV4. There is an example from a previous version which seams to be incompatible with version4 or 4.4 specifically. If i figure it out my self i'll post it here.

Nick

Menou and unome

Link to comment
Share on other sites

it seems there is only two things to do:

 

1/ add the following to catalog/includes/modules/sts_inc/sts_user_code.php

//Wishlist $Variable

$sts->start_capture();

require(DIR_WS_BOXES . 'wishlist.php');

$sts->stop_capture('wishlist', 'box'); // 'box' makes the system remove some html code before and after the box. Otherwise big mess!

 

2/ add the $wishlist variable to your template page

 

it works on my page so i hope it works on yours

Nick

Menou and unome

Link to comment
Share on other sites

Hello

 

I installed wishlist 3.5d on our shop and I have now following problem. If I click on the button "add to wishlist" nothting happens. The product will not appear on the wishlist. Could anybody help me to fix this problem?

 

Thanks!

Roland

Link to comment
Share on other sites

The forums are very slow for me - so forgive me if this is already posted...

 

Just installed the Wishlist report for the admin -

 

I was getting an SQL error (TABLE_WISHLIST not defined) -

 

I had to add this to catalog/admin/includes/database_tables.php:

 

define('TABLE_WISHLIST', 'customers_wishlist');

 

(It was already defined in the public area, but not in the admin area.)

 

Thanks for the great contrib!

 

Jim

Link to comment
Share on other sites

Some time ago I read in this forum something about moving the product from the wishlist to the cart.

I tried to find it back but did not succeded.

 

I implemented the 3.5d version and right now if I want to move the product to the cart (from the wishlist) the wishlist still contains the product after moving (copying).

 

How can I change that in such a way the product will be deleted from the wishlist?

 

Who can help me!

 

cheers

Gauthier

Link to comment
Share on other sites

Some time ago I read in this forum something about moving the product from the wishlist to the cart.

I tried to find it back but did not succeded.

 

I implemented the 3.5d version and right now if I want to move the product to the cart (from the wishlist) the wishlist still contains the product after moving (copying).

 

How can I change that in such a way the product will be deleted from the wishlist?

 

Who can help me!

 

cheers

Gauthier

 

 

The product is removed from the wishlist when they "actually" buy it. They have to checkout in order for it to be removed. It's a better way in my opinion.

Link to comment
Share on other sites

Hi, Ive instaled Wishlist 3.5d.zip and ive done all the steps correctly, when adding a product to the wishlist I get this error:

 

My Wish List contains:

 

1054 - Unknown column 'p.products_id' in 'on clause'

 

select pd.products_id, pd.products_name, pd.products_description, p.products_image, p.products_status, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products p, products_description pd left join specials s on p.products_id = s.products_id where pd.products_id = '1' and p.products_id = pd.products_id and pd.language_id = '4' order by products_name

 

[TEP STOP]

 

 

does anyone know how to over come this problem? what does this mean?

Edited by tolinho
Link to comment
Share on other sites

Hai Dennis,

I agree, so I will check in my implementation if it does. If so I am completely happy.

 

Thanks

Gauthier

 

The product is removed from the wishlist when they "actually" buy it. They have to checkout in order for it to be removed. It's a better way in my opinion.
Link to comment
Share on other sites

Hi, Ive instaled Wishlist 3.5d.zip and ive done all the steps correctly, when adding a product to the wishlist I get this error:

 

My Wish List contains:

 

1054 - Unknown column 'p.products_id' in 'on clause'

 

select pd.products_id, pd.products_name, pd.products_description, p.products_image, p.products_status, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products p, products_description pd left join specials s on p.products_id = s.products_id where pd.products_id = '1' and p.products_id = pd.products_id and pd.language_id = '4' order by products_name

 

[TEP STOP]

does anyone know how to over come this problem? what does this mean?

 

Does anyone have the solution for this? Did I do something rong? I really would like anyone to replay

 

Chears

Link to comment
Share on other sites

Change it to pd.products_id. Seems to work for some people.

 

 

Thanks for taking the time to reply.

What must I change? all fields that are p.products_id change them to pd.products_id ??

 

Could you be a little more specific, its just that i'm not very good with PHP.

 

Thank you

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