Tsimi

bm_wishlist.php

Feb 11th, 2015
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3.   $Id: Wish List Box revision 3
  4.   osCommerce, Open Source E-Commerce Solutions
  5.   http://www.oscommerce.com
  6.  
  7.   Released under the GNU General Public License
  8. */
  9.  
  10. /*******************************************************************
  11. ****** QUERY THE DATABASE FOR THE CUSTOMERS WISHLIST PRODUCTS ******
  12. *******************************************************************/
  13.  
  14. class bm_wishlist {
  15.     var $code = 'bm_wishlist';
  16.     var $group = 'boxes';
  17.     var $title;
  18.     var $description;
  19.     var $sort_order;
  20.     var $enabled = false;
  21.  
  22.     function bm_wishlist() {
  23.       $this->title = MODULE_BOXES_WISHLIST_TITLE;
  24.       $this->description = MODULE_BOXES_WISHLIST_DESCRIPTION;
  25.  
  26.       if ( defined('MODULE_BOXES_WISHLIST_STATUS') ) {
  27.         $this->sort_order = MODULE_BOXES_WISHLIST_SORT_ORDER;
  28.         $this->enabled = (MODULE_BOXES_WISHLIST_STATUS == 'True');
  29.  
  30.         $this->group = ((MODULE_BOXES_WISHLIST_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right');
  31.       }
  32.     }
  33.  
  34.     function execute() {
  35.       global $wishList, $currencies, $languages_id, $oscTemplate;
  36.  
  37.       $counter = $wishList->count_contents();
  38.       if ($counter > 0) {
  39.             $wishlist_box = '';
  40.         $wish_products = $wishList->get_wishlist_products();
  41.                 $n=sizeof($wish_products);
  42.             if ($n <= MAX_DISPLAY_WISHLIST_BOX) {
  43.           for ($i=0; $i<$n; $i++) {
  44.               $wishlist_box .= '<li>';
  45.             $wishlist_box .= $wish_products[$i]['quantity'] . '&nbsp;x&nbsp;';
  46.             $wishlist_box .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wish_products[$i]['id']) . '">';
  47.             $wishlist_box .= $wish_products[$i]['name'];
  48.             $wishlist_box .= '</a></li>';
  49.           }
  50.          
  51.           $wishlist_box .= '<li class="text-right"><hr>' . $currencies->format($wishList->show_total()) . '</li>';
  52.             }
  53.             $wishlist_box .= '<a href="' . tep_href_link(FILENAME_WISHLIST) . '">' . sprintf(TEXT_WISHLIST_COUNT, $counter) . '</a>';
  54.         } else {
  55.             $wishlist_box = '<p>' . MODULE_BOXES_WISHLIST_BOX_CART_EMPTY . '</p>';
  56.         }
  57.      
  58.           ob_start();
  59.       include(DIR_WS_MODULES . 'boxes/templates/wishlist.php');
  60.       $data = ob_get_clean();
  61.  
  62.       $oscTemplate->addBlock($data, $this->group);
  63.     }
  64.  
  65.     function isEnabled() {
  66.       return $this->enabled;
  67.     }
  68.  
  69.     function check() {
  70.       return defined('MODULE_BOXES_WISHLIST_STATUS');
  71.     }
  72.  
  73.     function install() {
  74.       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Wish List Box Module', 'MODULE_BOXES_WISHLIST_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  75.       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_WISHLIST_CONTENT_PLACEMENT', 'Right Column', 'Should the module be loaded in the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())");
  76.       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_WISHLIST_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
  77.     }
  78.  
  79.     function remove() {
  80.       tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  81.     }
  82.  
  83.     function keys() {
  84.       return array('MODULE_BOXES_WISHLIST_STATUS', 'MODULE_BOXES_WISHLIST_CONTENT_PLACEMENT', 'MODULE_BOXES_WISHLIST_SORT_ORDER');
  85.     }
  86.   }
  87. ?>
RAW Paste Data