????

Your IP : 216.73.216.174


Current Path : /home2/morganrand/www/store/
Upload File :
Current File : /home2/morganrand/www/store/wishlist_public.php

<?php
/*
  $Id: wishlist_public.php, 2.3.4 revision 3  2014/11/21 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, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$public_id . "'");
	if (tep_db_num_rows($customer_query) == 0) tep_redirect(tep_href_link(FILENAME_DEFAULT));
	$customer = tep_db_fetch_array($customer_query);

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

  if (isset($HTTP_POST_VARS['add_wishprod'])) {
		foreach ($HTTP_POST_VARS['add_wishprod'] as $key =>$value) {
			if ($key == $value) {
				$check_query = tep_db_query("select customers_wishlist_quantity from " . TABLE_WISHLIST . " where customers_id = '" . (int)$public_id . "' and products_id = '" . tep_db_input($value) . "'");
				if (tep_db_num_rows($check_query) == 1) { // make sure product is still in the wish list
				  $check = tep_db_fetch_array($check_query);
				  $attributes = array();
			    $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='" . (int)$public_id . "' and products_id = '" . tep_db_input($value) . "'");
          while ($wishlist_products_attributes = tep_db_fetch_array($wishlist_products_attributes_query)) {
					  $attributes[$wishlist_products_attributes['po']] = $wishlist_products_attributes['pov'];
				  }
			    $cart->add_cart($value, $cart->get_quantity($value)+$check['customers_wishlist_quantity'], $attributes);
				}
			}
		}
  	tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  }


 $breadcrumb->add($customer['customers_firstname'] . ' ' . $customer['customers_lastname'] . NAVBAR_TITLE_PUBLIC_WISHLIST, tep_href_link(FILENAME_WISHLIST_PUBLIC, 'public_id=' . $public_id, 'SSL'));
 
 require(DIR_WS_INCLUDES . 'template_top.php');
 $page = '';
 if (isset($_GET['page'])) $page = '&page=' . $_GET['page'];
?>

<h1><?php echo $customer['customers_firstname'] . ' ' . $customer['customers_lastname'] .  HEADING_TITLE2; ?></h1>
<div class="contentContainer">
<?php echo tep_draw_form('wishlist_form', tep_href_link(FILENAME_WISHLIST_PUBLIC, 'public_id=' . $public_id . $page, 'SSL'));
  if ($messageStack->size('wishlist') > 0) {
?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php echo $messageStack->output('wishlist'); ?></td>
  </tr>
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
</table>
<?php
  }

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

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

	if ($wishlist_split->number_of_rows > 0 && (PREV_NEXT_BAR_LOCATION == '1' || PREV_NEXT_BAR_LOCATION == '3')) {
?>

<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>
<?php
  }
?>
<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_QTY; ?></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)) {
      $products_query = tep_db_query("select * from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd  where pd.products_id = '" . (int)$wishlist['products_id'] . "' and p.products_id = pd.products_id and pd.language_id = " . (int)$languages_id);
      $products = tep_db_fetch_array($products_query);
			$products['specials_new_products_price'] = $products['sale_expires'] = '';
      $specials_query = tep_db_query("select specials_new_products_price, expires_date from " . TABLE_SPECIALS . " where products_id = '" . (int)$wishlist['products_id'] . "' and status = '1' order by specials_new_products_price, expires_date limit 1");
      if (tep_db_num_rows($specials_query)) {
        $specials = tep_db_fetch_array($specials_query);
        $products['specials_new_products_price'] = $specials['specials_new_products_price'];
			  $products['sale_expires'] = tep_date_short($specials['expires_date']);
      }

      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"><?php
			$image = '';
			if (isset($products['image_display']) && isset($products['image_folder'])) { // if using protected images contribution
        if ($products['image_display'] == 1) {
          $image = tep_image(DIR_WS_LANGUAGES . $language . '/images/' . 'no_picture.gif', TEXT_NO_PICTURE, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
        } elseif (($products['image_display'] != 2) && tep_not_null($products['products_image'])) {
          $image = tep_image(DIR_WS_IMAGES_THUMBS . $products['image_folder'] . $products['products_image'], $products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
        }
			} else { // using standard osCommerce images
			  $image = tep_image(DIR_WS_IMAGES . $products['products_image'], $products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
		  }
			if ($products['products_status'] == 0) {
			  echo $image; 
			} else {
        echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wishlist['products_id'], 'NONSSL') . '">' . $image . '</a>';
      } ?></td>
    <td valign="top" class="productListing-data" align="left" class="main"><?php echo $wishlist['customers_wishlist_quantity']; ?>&nbsp;&times;</td>
    <td valign="top" class="productListing-data" align="left" class="main"><strong><?php if ($products['products_status'] != 0) echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wishlist['products_id'], 'NONSSL') . '">';
     echo $products['products_name'];
     if ($products['products_status'] != 0) echo '</a>';
      ?></strong>
    <?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='" . (int)$public_id . "' and products_id = '" . tep_db_input($wishlist['products_id']) . "'");
      while ($wishlist_products_attributes = tep_db_fetch_array($wishlist_products_attributes_query)) {
        // 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 = '" . (int)$wishlist['products_id'] . "'
                                    and pa.options_id = '" . (int)$wishlist_products_attributes['po'] . "'
                                    and pa.options_id = popt.products_options_id
                                    and pa.options_values_id = '" . (int)$wishlist_products_attributes['pov'] . "'
                                    and pa.options_values_id = poval.products_options_values_id
                                    and popt.language_id = '" . (int)$languages_id . "'
                                    and poval.language_id = '" . (int)$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><em> ' . $attributes_values['products_options_name'] . ': ' . $attributes_values['products_options_values_name'] . '</em></small>';
      } // end while attributes for product

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

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

		if($cart->in_cart($wishlist['products_id'])) {
			echo '<br /><strong style="color: red">' . TEXT_ITEM_IN_CART . '</strong>';
		}

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

		if($products['products_status'] == 0) {
			echo '<br /><strong style="color: red">' . TEXT_ITEM_NOT_AVAILABLE . '</strong>';
		}

	  $i++;
?>
    </td>
    <td valign="top" class="productListing-data"><?php echo $products_price; ?></td>
    <td valign="top" class="productListing-data" align="center"><?php if ($products['products_status'] != 0) echo tep_draw_checkbox_field('add_wishprod[' . $wishlist['products_id'] . ']',$wishlist['products_id']); ?></td>
  </tr>
  <?php
    }
?>
</table>
<?php
  if ($wishlist_split->number_of_rows > 0 && (PREV_NEXT_BAR_LOCATION == '2' || PREV_NEXT_BAR_LOCATION == '3')) {
?>
<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>
<?php
	}
?>
<div style="text-align:right"><br /><?php echo tep_draw_button(BUTTON_TEXT_ADD_CART, 'cart', null, 'primary'); ?></div>
</form>
</div>
<?php
} else { // Nothing in the customers wishlist

?>
<div class="contentContainer">
  <div class="contentText"> <?php echo BOX_TEXT_NO_ITEMS; ?> </div>
  <div class="buttonSet"><span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?></span></div>
</div>
<?php
}
?>
<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>