Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

discxpress

Members
  • Posts

    935
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by discxpress

  1. 5 minutes ago, 14steve14 said:

    Are you sure it has not been moved to templates/default/includes/hooks/shop/sitewide which is where many of the hooks are now placed.

    Yes it's there. The error message threw me off. I got distracted. Thank you.

  2. On 7/3/2020 at 9:07 AM, ecartz said:

    Leave it where you had it in your previously posted code.  The only change from your previously posted code should be to switch the order of the two lines that I posted. 

    You could also switch two of the } but since they are identical, there doesn't seem to be any point.  The positions where they are are correct enough (if I were doing the change, I'd indent them to match everything else; but that won't affect functionality). 

    @raiwa I could never get it working. If you can, please PM me or post the code as you have it. Thank you.

  3. 6 minutes ago, ecartz said:

    @discxpress

    You have two lines in your code: 

    
    if ($GLOBALS['PHP_SELF'] == 'index.php') {
        function execute() {

    replace those two lines with

    
        function execute() {
            if ($GLOBALS['PHP_SELF'] == 'index.php') {

    I.e. swap the order of those two lines.

    The rest of the code can stay the same. 

    Where do I place ---> }

    I keep getting an error on line 78 when I remove it.

  4. 13 minutes ago, raiwa said:

    I said: "wrap the coding inside the execute function...."

    not "wrap the execute function...."

     

    It must be:

    
        function execute() {
          global $currencies, $currency, $request_type, $current_category_id;
    	if ($GLOBALS['PHP_SELF'] == 'index.php') {
    .........

     

    Sorry I misunderstood. Where to put } ?

    EDIT: Please show me how you have it in your code.

  5. <?php
    /*
      $Id: cm_header_shop_by_price.php
      $Loc: catalog/includes/modules/content/header/
    
      2020 Shop by Price 5.2 CE Phoenix
      by @raiwa
      [email protected]
      www.oscaddons.com
    
      Based on:
      Contribution by Meltus  http://www.highbarn-consulting.com
      Adapted for OsCommerce MS2 by Sylvio Ruiz [email protected]
      Modified by Hugues Deriau on 09/23/2006 - display the price ranges in the selected currency
      Modified by Glassraven for dropdown list 24/10/2006 www.glassraven.com
      Modified by -GuiGui- (http://www.gpuzin.com) - 07/03/2008 - fix the title and work with the contribution " Product Listing in Columns"
    
      Copyright (c) 2020 Rainer Schmied
      All rights reserved.
    
      Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    
      1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    
      2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    
      3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    
      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
      class cm_header_shop_by_price extends abstract_executable_module {
    
        const CONFIG_KEY_BASE = 'MODULE_CONTENT_HEADER_SHOP_BY_PRICE_';
    
        function __construct() {
          parent::__construct(__FILE__);
    
          $this->description .= '<p>by @raiwa <u><a target="_blank" href="http://www.oscaddons.com">www.oscaddons.com</a></u></p>';
    
        }
    if ($GLOBALS['PHP_SELF'] == 'index.php') {
        function execute() {
          global $currencies, $currency, $request_type, $current_category_id;
    
          $content_width = (int)MODULE_CONTENT_HEADER_SHOP_BY_PRICE_CONTENT_WIDTH;
    
          $price_ranges = Array();
    
          $price_ranges_array = explode(',', constant('MODULE_CONTENT_HEADER_SHOP_BY_PRICE_PRICE_RANGE_' . $currency));
          $price_ranges[0] =  MODULE_CONTENT_HEADER_SHOP_BY_PRICE_LESS_THAN .  $this->format0($price_ranges_array[0], false);
          for ($price_range=1; $price_range<sizeof($price_ranges_array); $price_range++) {
            $price_ranges[$price_range] = $this->format0($price_ranges_array[$price_range-1]). " − " . $this->format0($price_ranges_array[$price_range]);
          }
          $price_ranges[sizeof($price_ranges_array)] =  MODULE_CONTENT_HEADER_SHOP_BY_PRICE_MORE_THAN .  $this->format0($price_ranges_array[sizeof($price_ranges_array)-1]);
          $price_ranges[sizeof($price_ranges_array)+1] =  MODULE_CONTENT_HEADER_SHOP_BY_PRICE_ALL;
    
          $price_range_list = null;
          $price_range_list[] = array('id' => '0', 'text' => PULL_DOWN_DEFAULT );
    
          for ($range=1; $range<sizeof($price_ranges)+1; $range++) {
            $price_range_list[] = array('id' => $range, 'text' => $price_ranges[$range-1] );
          }
    
          $range = null;
          if ( isset($_GET['range']) ) {
            $range = $_GET['range'];
          } elseif ( isset($_GET['lrange']) ) {
            $range = $_GET['lrange']+1;
          }
          
       $tpl_data = [ 'group' => $this->group, 'file' => __FILE__ ];
          include 'includes/modules/content/cm_template.php';
        }
    }
        protected function get_parameters() {
          $config_parameters = [
            'MODULE_CONTENT_HEADER_SHOP_BY_PRICE_STATUS' => [
              'title' => 'Enable Shop by Price Module',
              'value' => 'True',
              'desc' => 'Do you want to add the module to your shop?',
              'set_func' => "tep_cfg_select_option(['True', 'False'], ",
            ],
            'MODULE_CONTENT_HEADER_SHOP_BY_PRICE_CONTENT_WIDTH' => [
              'title' => 'Content Width',
              'value' => '4',
              'desc' => 'What width container should the content be shown in?',
              'set_func' => "tep_cfg_select_option(['12', '11', '10', '9', '8', '7', '6', '5', '4', '3', '2', '1'], ",
            ],
            'MODULE_CONTENT_HEADER_SHOP_BY_PRICE_SORT_ORDER' => [
              'title' => 'Sort Order',
              'value' => '25',
              'desc' => 'Sort order of display. Lowest is displayed first.',
            ],
            'MODULE_CONTENT_HEADER_SHOP_BY_PRICE_USE_FAST_TAX_QUERY' => [
              'title' => 'Use fast Tax Query',
              'value' => 'True',
              'desc' => 'Should work for most shops with standard tax settings.<br>Set to false if you have very complicate tax sttings with several Tax zones/types and get missing products in range results.',
              'set_func' => "tep_cfg_select_option(['True', 'False'], ",
            ],
            'MODULE_CONTENT_HEADER_SHOP_BY_PRICE_USE_DECIMAL' => [
              'title' => 'Use decimal places',
              'value' => 'False',
              'desc' => 'Do you want to use decimal places for the price ranges?',
              'set_func' => "tep_cfg_select_option(['True', 'False'], ",
            ],
          ];
          
          require_once(DIR_FS_CATALOG . 'includes/system/versioned/1.0.7.4/currencies.php');
          $currencies = new currencies();
          foreach($currencies->currencies as $key => $value) {
            $config_parameters['MODULE_CONTENT_HEADER_SHOP_BY_PRICE_PRICE_RANGE_' . $key] = [
                'title' => 'Price Range  ' . $key,
                'value' => '1,2,3,5,10',
                'desc' => 'Price Range Steps separated by comma for ' . $key . ' currency.<br>Default:"10,20,30,50,100"<br>If decimals, use point for decimal separator. Example: 2.50',
            ];
          }
          
          return $config_parameters;
          
        }
    
        function format0($number, $currency_type = '', $currency_value = '') {
          global $currencies, $currency, $calculate_currency_value;
    
          if (empty($currency_type)) $currency_type = $currency;
    
          if ( defined('MODULE_CONTENT_HEADER_SHOP_BY_PRICE_USE_DECIMAL') && MODULE_CONTENT_HEADER_SHOP_BY_PRICE_USE_DECIMAL == 'True') {
            if ($calculate_currency_value == true) {
              $rate = (tep_not_null($currency_value)) ? $currency_value : $currencies->currencies[$currency_type]['value'];
              $format_string = $currencies->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $currencies->currencies[$currency_type]['decimal_places']), $currencies->currencies[$currency_type]['decimal_places'], $currencies->currencies[$currency_type]['decimal_point'], $currencies->currencies[$currency_type]['thousands_point']) . $currencies->currencies[$currency_type]['symbol_right'];
            } else {
              $format_string = $currencies->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $currencies->currencies[$currency_type]['decimal_places']), $currencies->currencies[$currency_type]['decimal_places'], $currencies->currencies[$currency_type]['decimal_point'], $currencies->currencies[$currency_type]['thousands_point']) . $currencies->currencies[$currency_type]['symbol_right'];
            }
          } else {
            if ($calculate_currency_value == true) {
              $rate = (tep_not_null($currency_value)) ? $currency_value : $currencies->currencies[$currency_type]['value'];
              $format_string = $currencies->currencies[$currency_type]['symbol_left'] . number_format(tep_round(round($number * $rate, $round_places), $currencies->currencies[$currency_type]['decimal_places']), 0, $currencies->currencies[$currency_type]['decimal_point'], $currencies->currencies[$currency_type]['thousands_point']) . $currencies->currencies[$currency_type]['symbol_right'];
            } else {
              $format_string = $currencies->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $currencies->currencies[$currency_type]['decimal_places']), 0, $currencies->currencies[$currency_type]['decimal_point'], $currencies->currencies[$currency_type]['thousands_point']) . $currencies->currencies[$currency_type]['symbol_right'];
            }
          }
    
          return $format_string;
        }
      }

    @raiwa

  6. 1 hour ago, raiwa said:

    wrap all coding inside the execute function of the header module inside this condition:

    
    if ($GLOBALS['PHP_SELF'] == 'index.php') {
    
    ..............
    
    }

    this will show the module only on index.php

    That code removed it from all pages.

  7. 1 minute ago, raiwa said:

    1. It works for me and links to the advanced search page. Must be something in your store. However the back button didn't exist in the previous versions. If you wish, just remove it.

    2. This was always like this. If you wish to show it only on certain pages, add a $PHP_SELF check to the module.

    1. It may be the button spinner causing it. I may consider removing it.

    2. Ok. I don't know know anything about $PHP_SELF check 😄 I wish I knew how to code.

  8. @raiwa I'm using Phoenix 1.0.7.4 and this is the error on catalog/shop_by_price.php

    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 'ORDER BY final_price , pd.products_name LIMIT 0, 20' at line 1
    
    select distinct p.products_id, m.*, p.*, pd.*, p.products_quantity as in_stock, 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, if(s.status, 1, 0) as is_special from products p left join manufacturers m using(manufacturers_id) left join specials s on p.products_id = s.products_id, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '5748') and (IF(s.status, s.specials_new_products_price, p.products_price) >= 10) and (IF(s.status, s.specials_new_products_price, p.products_price) <= 20) order by final_price, pd.products_name ORDER BY final_price , pd.products_name LIMIT 0, 20

    I think and hope it will work if this is resolved.

  9. On 3/19/2020 at 6:54 AM, ecartz said:
    
    <script>$(document).ready(function() { $('button[name="wishlist"]').bind('click', function() {
        let input = document.createElement('input');
    
        input.setAttribute('type', 'hidden');
        input.setAttribute('name', 'wishlist');
        input.setAttribute('value', 'wishlist');
    
        let form = $(this).closest('form');
        form.unbind('submit');
        form.append(input);
        form.submit();
    
        return false;
      });});
    </script>

     

    Yes this works! Thanks Matt @ecartz

  10. 10 minutes ago, ecartz said:

    The problem that LeeFoster identified was a conflict with another App.  If he turned off the header_tag module from the other App, he could get the Wishlist to work.  That App has a header_tag module. 

    The ideal would be to add this as its own header_tag module that adds to footer_scripts but for testing purposes, anything that adds to footer_scripts would probably work.  For testing purposes (to verify that it works), you could add it to template_bottom.  But that would put it on every page even though it's only needed on the product_info page. 

    When I added that script to template_bottom it didn't work. The same behavior. There's code in application_top: 

    // BOF WISHLIST
    // wishlist data
    	if (!tep_session_is_registered('wishList') || !is_object($wishList)) {
    		tep_session_register('wishList');
    		$wishList = new wishlist;
    	}
    	
    //Wishlist actions (must be before shopping cart actions)
      if (isset($_POST['wishlist'])) {
    	  if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
          $attributes = isset($_POST['id']) ? $_POST['id'] : '';
    
            // php 5
            $qty = isset($_POST['qty']) ? (int)$_POST['qty'] : 1;
            // php 7
            // $qty = (int)($_POST['qty'] ?? 1);
    
          $wishList->add_wishlist($_POST['products_id'], $wishList->get_quantity(tep_get_uprid($_POST['products_id'], $attributes))+$qty, $attributes);
    	  }
    		if (WISHLIST_REDIRECT ==  'No') tep_redirect(tep_href_link('product_info.php', 'products_id=' . $_POST['products_id']));
    	  tep_redirect(tep_href_link('wishlist.php'));
      }
    // EOF WISHLIST

    Then there's the class file in which does the work of the button. As @LeeFoster stated it works once the Ajax buttons is turned off. 

  11. 6 hours ago, ecartz said:
    
    <script>$(document).ready(function(){ $('button[name="wishlist"]').bind('click', function() {
        let input = document.createElement('input');
    
        input.setAttribute('type', 'hidden');
        input.setAttribute('name', 'wishlist');
        input.setAttribute('value', 'wishlist');
    
        let form = $(this).parents('form:first');
        form.appendChild(input);
        form.submit();
    
        return false;
      }});
    </script>

    I think that this would fix it. 

    To test it, you could add this into the existing header tag module with which you are having trouble, as that already adds scripts to the footer.  But you might then want to move it into its own module or hook after establishing that it works. 

    The problem is that the AJAX submission is not passing which button was clicked to submit the form.  Which makes sense because there is only one button in the default install.  So  if Javascript is running, this adds a form input to the form when that button is clicked. 

    Hmmm. You threw me off when you said add to existing header tag module. I believe this version doesn't have that. But I also have no need to doubt you because your level of code is light years beyond my understanding. So I'll place it around until I find the correct spot.

    Thanks for your help sir.

  12. From my understanding, all the work is done from this block of code

    // BOF WISHLIST
    // wishlist data
    	if (!tep_session_is_registered('wishList') || !is_object($wishList)) {
    		tep_session_register('wishList');
    		$wishList = new wishlist;
    	}
    	
    //Wishlist actions (must be before shopping cart actions)
      if (isset($_POST['wishlist'])) {
    	  if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
          $attributes = isset($_POST['id']) ? $_POST['id'] : '';
    
            // php 5
    //        $qty = isset($_POST['qty']) ? (int)$_POST['qty'] : 1;
            // php 7
             $qty = (int)($_POST['qty'] ?? 1);
    
          $wishList->add_wishlist($_POST['products_id'], $wishList->get_quantity(tep_get_uprid($_POST['products_id'], $attributes))+$qty, $attributes);
    	  }
    		if (WISHLIST_REDIRECT ==  'No') tep_redirect(tep_href_link('product_info.php', 'products_id=' . $_POST['products_id']));
    	  tep_redirect(tep_href_link('wishlist.php'));
      }
    // EOF WISHLIST

    @kgtee @ecartz my php version is 7.3

  13. 1 minute ago, ecartz said:

    I'm pretty sure that this only happens in some browsers.  You may want to find out where @kgtee has this installed and check the behavior there. 

    Or post what browser you're using so people trying to debug can use the same one. 

    I use latest version of Chrome.

  14. 5 hours ago, kgtee said:

    I have been using the wishlist addon on my heavily modified 1.0.1.3 without any issue. Today I tried to migrate it to 1.0.5.2 and there seems to be no problem. Anyone interested may try this version.

    Wishlist.zip

    I just installed your version. here's the errors:

    Stack trace:
    #0 /home/xxxxxxxxxx/public_html/includes/system/versioned/1.0.4.0/osc_template.php(147): cm_navbar->execute()
    #1 /home/xxxxxxxxxx/public_html/includes/template_top.php(58): oscTemplate->getContent('navigation')
    #2 /home/xxxxxxxxxx/public_html/index.php(35): require('/home/q4p7grzvy...')
    #3 {main}
      thrown in /home/xxxxxxxxxx/public_html/includes/modules/content/navigation/cm_navbar.php on line 58
    [18-Mar-2020 06:02:02 UTC] PHP Fatal error:  Uncaught Error: Class 'nb_wishlist' not found in /home/xxxxxxxxxx/public_html/includes/modules/content/navigation/cm_navbar.php:58
    Stack trace:
    #0 /home/xxxxxxxxxx/public_html/includes/system/versioned/1.0.4.0/osc_template.php(147): cm_navbar->execute()
    #1 /home/xxxxxxxxxx/public_html/includes/template_top.php(58): oscTemplate->getContent('navigation')
    #2 /home/xxxxxxxxxx/public_html/index.php(35): require('/home/q4p7grzvy...')
    #3 {main}
      thrown in /home/xxxxxxxxxx/public_html/includes/modules/content/navigation/cm_navbar.php on line 58

    Also note that when you click save to favorites, an item is added to shopping cart. Thanks

×
×
  • Create New...