Tsimi

catalog/wishlist_public.php

Feb 11th, 2015
22
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3.   $Id: wishlist_public.php, 2.3.4 revision 3  2014/11/21 Dennis Blake
  4.   osCommerce, Open Source E-Commerce Solutions
  5.   http://www.oscommerce.com
  6.  
  7.   Released under the GNU General Public License
  8. */
  9.  
  10.   require('includes/application_top.php');
  11.   require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_WISHLIST);
  12.  
  13.   if (!isset($_GET['public_id'])) tep_redirect(tep_href_link(FILENAME_DEFAULT));
  14.  
  15.   $public_id = $_GET['public_id'];
  16.  
  17. /*******************************************************************
  18. ****************** QUERY CUSTOMER INFO FROM ID *********************
  19. *******************************************************************/
  20.  
  21.     $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$public_id . "'");
  22.     if (tep_db_num_rows($customer_query) == 0) tep_redirect(tep_href_link(FILENAME_DEFAULT));
  23.     $customer = tep_db_fetch_array($customer_query);
  24.  
  25. /*******************************************************************
  26. ****************** ADD PRODUCT TO SHOPPING CART ********************
  27. *******************************************************************/
  28.  
  29.   if (isset($HTTP_POST_VARS['add_wishprod'])) {
  30.         foreach ($HTTP_POST_VARS['add_wishprod'] as $key =>$value) {
  31.             if ($key == $value) {
  32.                 $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) . "'");
  33.                 if (tep_db_num_rows($check_query) == 1) { // make sure product is still in the wish list
  34.                   $check = tep_db_fetch_array($check_query);
  35.                   $attributes = array();
  36.                 $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) . "'");
  37.           while ($wishlist_products_attributes = tep_db_fetch_array($wishlist_products_attributes_query)) {
  38.                       $attributes[$wishlist_products_attributes['po']] = $wishlist_products_attributes['pov'];
  39.                   }
  40.                 $cart->add_cart($value, $cart->get_quantity($value)+$check['customers_wishlist_quantity'], $attributes);
  41.                 }
  42.             }
  43.         }
  44.     tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  45.   }
  46.  
  47.  
  48.  $breadcrumb->add($customer['customers_firstname'] . ' ' . $customer['customers_lastname'] . NAVBAR_TITLE_PUBLIC_WISHLIST, tep_href_link(FILENAME_WISHLIST_PUBLIC, 'public_id=' . $public_id, 'SSL'));
  49.  
  50.  require(DIR_WS_INCLUDES . 'template_top.php');
  51.  $page = '';
  52.  if (isset($_GET['page'])) $page = '&page=' . $_GET['page'];
  53. ?>
  54.  
  55. <h1><?php echo $customer['customers_firstname'] . ' ' . $customer['customers_lastname'] .  HEADING_TITLE2; ?></h1>
  56. <div class="contentContainer">
  57. <?php echo tep_draw_form('wishlist_form', tep_href_link(FILENAME_WISHLIST_PUBLIC, 'public_id=' . $public_id . $page, 'SSL'));
  58.  
  59.   if ($messageStack->size('wishlist') > 0) {
  60.     echo $messageStack->output('wishlist');
  61.   }
  62.  
  63. /*******************************************************************
  64. ****** QUERY THE DATABASE FOR THE CUSTOMERS WISHLIST PRODUCTS ******
  65. *******************************************************************/
  66.  
  67.   $wishlist_query_raw = "select * from " . TABLE_WISHLIST . " where customers_id = '" . (int)$public_id . "'";
  68.   $wishlist_split = new splitPageResults($wishlist_query_raw, MAX_DISPLAY_WISHLIST_PRODUCTS);
  69.   $wishlist_query = tep_db_query($wishlist_split->sql_query);
  70.   if (tep_db_num_rows($wishlist_query)) {
  71.  
  72.     if ($wishlist_split->number_of_rows > 0 && (PREV_NEXT_BAR_LOCATION == '1' || PREV_NEXT_BAR_LOCATION == '3')) {
  73. ?>
  74. <div class="row">
  75.   <div class="col-sm-6 pagenumber hidden-xs">
  76.     <?php echo $wishlist_split->display_count(TEXT_DISPLAY_NUMBER_OF_WISHLIST); ?>
  77.   </div>
  78.   <div class="col-sm-6">
  79.     <div class="pull-right pagenav"><ul class="pagination"><?php echo $wishlist_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></ul></div>
  80.     <span class="pull-right"><?php echo TEXT_RESULT_PAGE; ?></span>
  81.   </div>
  82. </div>
  83. <?php
  84.   }
  85. ?>
  86.   <table class="table table-striped table-hover table-responsive">
  87.   <thead>
  88.   <tr>
  89.     <th class="text-center"><?php echo BOX_TEXT_IMAGE; ?></th>
  90.     <th class="text-center"><?php echo BOX_TEXT_QTY; ?></th>
  91.     <th><?php echo BOX_TEXT_PRODUCT; ?></th>
  92.     <th><?php echo BOX_TEXT_PRICE; ?></th>
  93.     <th class="text-center"><?php echo BOX_TEXT_SELECT; ?></th>
  94.   </tr>
  95.  </thead>
  96.  <tbody>
  97.   <?php
  98. /*******************************************************************
  99. ***** LOOP THROUGH EACH PRODUCT ID TO DISPLAY IN THE WISHLIST ******
  100. *******************************************************************/
  101.       $i = 0;
  102.     while ($wishlist = tep_db_fetch_array($wishlist_query)) {
  103.       $wish_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);
  104.       $wish_products = tep_db_fetch_array($wish_products_query);
  105.             $wish_products['specials_new_products_price'] = $wish_products['sale_expires'] = '';
  106.       $wish_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");
  107.       if (tep_db_num_rows($wish_specials_query)) {
  108.         $wish_specials = tep_db_fetch_array($wish_specials_query);
  109.         $wish_products['specials_new_products_price'] = $wish_specials['specials_new_products_price'];
  110.               $wish_products['sale_expires'] = tep_date_short($wish_specials['expires_date']);
  111.       }
  112. ?>
  113.  
  114.   <tr>
  115.     <td><?php
  116.             $image = '';
  117.             if (isset($wish_products['image_display']) && isset($wish_products['image_folder'])) { // if using protected images contribution
  118.         if ($wish_products['image_display'] == 1) {
  119.           $image = tep_image(DIR_WS_LANGUAGES . $language . '/images/' . 'no_picture.gif', TEXT_NO_PICTURE, SMALL_IMAGE_WIDTH*0.5, SMALL_IMAGE_HEIGHT*0.5);
  120.         } elseif (($wish_products['image_display'] != 2) && tep_not_null($wish_products['products_image'])) {
  121.           $image = tep_image(DIR_WS_IMAGES_THUMBS . $wish_products['image_folder'] . $wish_products['products_image'], $wish_products['products_name'], SMALL_IMAGE_WIDTH*0.5, SMALL_IMAGE_HEIGHT*0.5);
  122.         }
  123.             } else { // using standard osCommerce images
  124.               $image = tep_image(DIR_WS_IMAGES . $wish_products['products_image'], $wish_products['products_name'], SMALL_IMAGE_WIDTH*0.5, SMALL_IMAGE_HEIGHT*0.5);
  125.           }
  126.             if ($wish_products['products_status'] == 0) {
  127.               echo $image;
  128.             } else {
  129.         echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wishlist['products_id'], 'NONSSL') . '">' . $image . '</a>';
  130.       } ?></td>
  131.     <td class="text-center"><?php echo $wishlist['customers_wishlist_quantity']; ?>&nbsp;x</td>
  132.     <td><strong><?php if ($wish_products['products_status'] != 0) echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wishlist['products_id'], 'NONSSL') . '">';
  133.      echo $wish_products['products_name'];
  134.      if ($wish_products['products_status'] != 0) echo '</a>';
  135.       ?></strong>
  136.     <?php
  137.  
  138. /*******************************************************************
  139. ******** THIS IS THE WISHLIST CODE FOR PRODUCT ATTRIBUTES  *********
  140. *******************************************************************/
  141.  
  142.       $attributes_addon_price = 0;
  143.       // Now get and populate product attributes
  144.       $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']) . "'");
  145.       while ($wishlist_products_attributes = tep_db_fetch_array($wishlist_products_attributes_query)) {
  146.         // Output the appropriate attribute name
  147.         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
  148.                                    from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
  149.                                    where pa.products_id = '" . (int)$wishlist['products_id'] . "'
  150.                                    and pa.options_id = '" . (int)$wishlist_products_attributes['po'] . "'
  151.                                    and pa.options_id = popt.products_options_id
  152.                                    and pa.options_values_id = '" . (int)$wishlist_products_attributes['pov'] . "'
  153.                                    and pa.options_values_id = poval.products_options_values_id
  154.                                    and popt.language_id = '" . (int)$languages_id . "'
  155.                                    and poval.language_id = '" . (int)$languages_id . "'");
  156.         $attributes_values = tep_db_fetch_array($attributes);
  157.         if ($attributes_values['price_prefix'] == '+') {
  158.           $attributes_addon_price += $attributes_values['options_values_price'];
  159.               } else if ($attributes_values['price_prefix'] == '-') {
  160.           $attributes_addon_price -= $attributes_values['options_values_price'];
  161.               }
  162.         echo '<br /><small><em> ' . $attributes_values['products_options_name'] . ': ' . $attributes_values['products_options_values_name'] . '</em></small>';
  163.       } // end while attributes for product
  164.  
  165.       if (tep_not_null($wish_products['specials_new_products_price'])) {
  166.         $products_price = '<del>' . $currencies->display_price($wish_products['products_price']+$attributes_addon_price, tep_get_tax_rate($wish_products['products_tax_class_id']), $wishlist['customers_wishlist_quantity']) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($wish_products['specials_new_products_price']+$attributes_addon_price, tep_get_tax_rate($wish_products['products_tax_class_id']), $wishlist['customers_wishlist_quantity']);
  167.                 if (tep_not_null($wish_products['sale_expires'])) $products_price .= '<br /><small>' . BOX_TEXT_SALE_EXPIRES .  $wish_products['sale_expires'] . '</small>';
  168.                 $products_price .= '</span>';
  169.       } else {
  170.         $products_price = $currencies->display_price($wish_products['products_price']+$attributes_addon_price, tep_get_tax_rate($wish_products['products_tax_class_id']), $wishlist['customers_wishlist_quantity']);
  171.       }
  172.  
  173.  
  174. /*******************************************************************
  175. ******* CHECK TO SEE IF PRODUCT HAS BEEN ADDED TO THEIR CART *******
  176. *******************************************************************/
  177.  
  178.         if($cart->in_cart($wishlist['products_id'])) {
  179.             echo '<br /><strong style="color: red">' . TEXT_ITEM_IN_CART . '</strong>';
  180.         }
  181.  
  182. /*******************************************************************
  183. ********** CHECK TO SEE IF PRODUCT IS NO LONGER AVAILABLE **********
  184. *******************************************************************/
  185.  
  186.         if($wish_products['products_status'] == 0) {
  187.             echo '<br /><strong style="color: red">' . TEXT_ITEM_NOT_AVAILABLE . '</strong>';
  188.         }
  189.  
  190.       $i++;
  191. ?>
  192.     </td>
  193.     <td><?php echo $products_price; ?></td>
  194.     <td class="text-center">
  195.         <?php if (($wish_products['products_status'] == 0) || ($cart->in_cart($wishlist['products_id']))) {
  196.                 echo '';
  197.               } else {
  198.                 echo tep_draw_checkbox_field('add_wishprod[' . $wishlist['products_id'] . ']',$wishlist['products_id']);
  199.               }
  200.         ?>
  201.     </td>
  202.   </tr>
  203.   <?php
  204.     }
  205. ?>
  206. <tbody>
  207. </table>
  208. <?php
  209.   if ($wishlist_split->number_of_rows > 0 && (PREV_NEXT_BAR_LOCATION == '2' || PREV_NEXT_BAR_LOCATION == '3')) {
  210. ?>
  211. <div class="row">
  212.   <div class="col-sm-6 pagenumber hidden-xs">
  213.     <?php echo $wishlist_split->display_count(TEXT_DISPLAY_NUMBER_OF_WISHLIST); ?>
  214.   </div>
  215.   <div class="col-sm-6">
  216.     <div class="pull-right pagenav"><ul class="pagination"><?php echo $wishlist_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></ul></div>
  217.     <span class="pull-right"><?php echo TEXT_RESULT_PAGE; ?></span>
  218.   </div>
  219. </div>
  220. <?php
  221.     }
  222. ?>
  223. <p class="text-right"><?php echo tep_draw_button(BUTTON_TEXT_ADD_CART, 'glyphicon glyphicon-shopping-cart', null, 'primary', '', 'btn btn-success'); ?></p>
  224. </form>
  225.  
  226. <?php
  227. } else { // Nothing in the customers wishlist
  228.  
  229. ?>
  230.   <div class="alert alert-danger"><?php echo BOX_TEXT_NO_ITEMS; ?></div>
  231.   <div class="text-right"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'glyphicon glyphicon-chevron-right', tep_href_link(FILENAME_DEFAULT)); ?></div>
  232. <?php
  233. }
  234. ?>
  235. </div> <!-- .contentContainer //-->
  236. <?php
  237.   require(DIR_WS_INCLUDES . 'template_bottom.php');
  238.   require(DIR_WS_INCLUDES . 'application_bottom.php');
  239. ?>
RAW Paste Data