Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

quote button on index product listing for new product of the month


ce7

Recommended Posts

Hi there,

I have BS Frozen version install with Email for quote, modified the code, all seems doing what I like to show, except the button on index page, code related to
catalog/includes/modules/product_listing.php    and
catalog/includes/modules/new_products.php

My goal is to change the new product of the month BUY button next to View button,
if the product price is 0, then QUOTE button replace with BUY button.

I have modified two files that will change buttons from BUY to QUOTE,
my problem here is that if will not filter if price is < 0, it is just simplely change all button BUY to QUOTE.

However it does change conditionally when click on what's new infobox page. Please find the images for your reference.

Please compare the product KEYBOARD

====================
error without condition < 0 applied
====================

898155877_quotebutton-01-NewProductonindextproductlisting.PNG.85bb9f9e25ad030a8536f8cf42e0a2e2.PNG

====================
condition < 0 applied on What's New page
====================

1058490611_quotebutton-02-NewProductonindextwhatsnew.PNG.2bb5504115d22625974a5ed542a467ab.PNG

there are two files related to this change:

---------------------------------------------------------------------------------------------------------------------------------------------
catalog/includes/modules/content/index/cm_in_new_products.php
---------------------------------------------------------------------------------------------------------------------------------------------

	<?php
/*
  $Id$
	  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
	  Copyright (c) 2016 osCommerce
	  Released under the GNU General Public License
*/
	  class cm_i_new_products {
    var $code;
    var $group;
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;
	    function __construct() {
      $this->code = get_class($this);
      $this->group = basename(dirname(__FILE__));
	      $this->title = MODULE_CONTENT_NEW_PRODUCTS_TITLE;
      $this->description = MODULE_CONTENT_NEW_PRODUCTS_DESCRIPTION;
      $this->description .= '<div class="secWarning">' . MODULE_CONTENT_BOOTSTRAP_ROW_DESCRIPTION . '</div>';
	      if ( defined('MODULE_CONTENT_NEW_PRODUCTS_STATUS') ) {
        $this->sort_order = MODULE_CONTENT_NEW_PRODUCTS_SORT_ORDER;
        $this->enabled = (MODULE_CONTENT_NEW_PRODUCTS_STATUS == 'True');
      }
    }
	    function execute() {
      global $oscTemplate, $new_products_category_id, $languages_id, $currencies, $PHP_SELF, $currency;
      
      $content_width = MODULE_CONTENT_NEW_PRODUCTS_CONTENT_WIDTH;
      $product_width = MODULE_CONTENT_NEW_PRODUCTS_DISPLAY_EACH;
      
      if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
        $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price, p.products_quantity as in_stock, if(s.status, 1, 0) as is_special from products p left join specials s on p.products_id = s.products_id, products_description pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_id desc limit " . (int)MODULE_CONTENT_NEW_PRODUCTS_MAX_DISPLAY);
      } else {
        $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price, p.products_quantity as in_stock, if(s.status, 1, 0) as is_special from products p left join specials s on p.products_id = s.products_id, products_description pd, products_to_categories p2c, categories c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_id desc limit " . (int)MODULE_CONTENT_NEW_PRODUCTS_MAX_DISPLAY);
      }
      
      $num_new_products = tep_db_num_rows($new_products_query);
	      if ($num_new_products > 0) {
      
    //BOF 8522 Email For Quote v1.2
      if (is_email_for_quote($new_products['products_price'])) {
        $price_display = show_email_for_quote($new_products);
      } else {
        $price_display = $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']));
      }
    //EOF 8522 Email For Quote v1.2       
      
        ob_start();
        include('includes/modules/content/' . $this->group . '/templates/tpl_' . basename(__FILE__));
        $template = ob_get_clean();
        
        $oscTemplate->addContent($template, $this->group);
      }
    }
	    function isEnabled() {
      return $this->enabled;
    }
	    function check() {
      return defined('MODULE_CONTENT_NEW_PRODUCTS_STATUS');
    }
	    function install() {
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable New Products Module', 'MODULE_CONTENT_NEW_PRODUCTS_STATUS', 'True', 'Do you want to enable this module?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Width', 'MODULE_CONTENT_NEW_PRODUCTS_CONTENT_WIDTH', '12', 'What width container should the content be shown in? (12 = full width, 6 = half width).', '6', '2', 'tep_cfg_select_option(array(\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Display', 'MODULE_CONTENT_NEW_PRODUCTS_MAX_DISPLAY', '6', 'Maximum Number of products that should show in this module?', '6', '3', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Product Width', 'MODULE_CONTENT_NEW_PRODUCTS_DISPLAY_EACH', '3', 'What width container should each product be shown in? (12 = full width, 6 = half width).', '6', '4', 'tep_cfg_select_option(array(\'12\', \'11\', \'10\', \'9\', \'8\', \'7\', \'6\', \'5\', \'4\', \'3\', \'2\', \'1\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_NEW_PRODUCTS_SORT_ORDER', '300', 'Sort order of display. Lowest is displayed first.', '6', '5', now())");
    }
	    function remove() {
      tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }
	    function keys() {
      return array('MODULE_CONTENT_NEW_PRODUCTS_STATUS', 'MODULE_CONTENT_NEW_PRODUCTS_CONTENT_WIDTH', 'MODULE_CONTENT_NEW_PRODUCTS_MAX_DISPLAY', 'MODULE_CONTENT_NEW_PRODUCTS_DISPLAY_EACH', 'MODULE_CONTENT_NEW_PRODUCTS_SORT_ORDER');
    }
  }
?>
	


---------------------------------------------------------------------------------------------------------------------------------------------
catalog/includes/modules/content/index/templates/tpl_cm_i_new_products.php
---------------------------------------------------------------------------------------------------------------------------------------------

 
	<div class="col-sm-<?php echo $content_width; ?> cm-i-new-products">
	  <h3 class="h3"><?php echo sprintf(MODULE_CONTENT_NEW_PRODUCTS_HEADING, strftime('%B')); ?></h3>
 
  <div class="row list-group" itemscope itemtype="http://schema.org/ItemList">
    <meta itemprop="numberOfItems" content="<?php echo (int)$num_new_products; ?>" />
    <?php
    
    //BOF 8522 Email For Quote v1.2
      if (is_email_for_quote($new_products['products_price'])) {
        $price_display = show_email_for_quote($new_products);
      } else {
        $price_display = $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']));
      }
    //EOF 8522 Email For Quote v1.2
        
    while ($new_products = tep_db_fetch_array($new_products_query)) {
      ?>
    <div class="col-sm-<?php echo $product_width; ?>" itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Product">
      <div class="thumbnail equal-height is-product" data-is-special="<?php echo (int)$new_products['is_special']; ?>">
        <a href="<?php echo tep_href_link('product_info.php', 'products_id=' . (int)$new_products['products_id']); ?>"><?php echo tep_image('images/' . $new_products['products_image'], htmlspecialchars($new_products['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'itemprop="image"'); ?></a>
        <div class="caption">
          <p class="text-center"><a itemprop="url" href="<?php echo tep_href_link('product_info.php', 'products_id=' . (int)$new_products['products_id']); ?>"><span itemprop="name"><?php echo $new_products['products_name']; ?></span></a></p>
          <hr>
          <!-- BOF 8522 Email For Quote for v1.2 -  Jan 2013 -->
          <?php
                if (!is_email_for_quote($products_new['products_price'])) {
          ?>
          <!-- BOF 8522 Email For Quote for v1.2 -  Jan 2013 -->
          <p class="text-center" itemprop="offers" itemscope itemtype="http://schema.org/Offer"><meta itemprop="priceCurrency" content="<?php echo tep_output_string($currency); ?>" /><span itemprop="price" content="<?php echo $currencies->display_raw($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])); ?>"><?php echo $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])); ?></span></p>
          <!-- BOF 8522 Email For Quote for v1.2 -  Jan 2013 -->
          <?php
                }
          ?>
          <!-- BOF 8522 Email For Quote for v1.2 -  Jan 2013 -->
          
          <div class="text-center">
            <div class="btn-group">
              <a href="<?php echo tep_href_link('product_info.php', tep_get_all_get_params(array('action')) . 'products_id=' . (int)$new_products['products_id']); ?>" class="btn btn-default" role="button"><?php echo MODULE_CONTENT_NEW_PRODUCTS_BUTTON_VIEW; ?></a>
          <!-- BOF 8522 Email For Quote for v1.2 -  Jan 2013 -->
          <?php
                if (!is_email_for_quote($products_new['products_price'])) {
          ?>
          <!-- BOF 8522 Email For Quote for v1.2 -  Jan 2013 -->
              <?php
              echo '<a href="' . tep_href_link($PHP_SELF, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$new_products['products_id']) . '" data-has-attributes="' . ((tep_has_product_attributes((int)$new_products['products_id']) === true) ? '1' : '0') . '" data-in-stock="' . (int)$new_products['in_stock'] . '" data-product-id="' . (int)$new_products['products_id'] . '" class="btn btn-success btn-index btn-buy" role="button">' . MODULE_CONTENT_NEW_PRODUCTS_BUTTON_BUY . '</a>';
              ?>
          <!-- BOF 8522 Email For Quote for v1.2 -  Jan 2013 -->
          <?php
          } else {
              echo show_email_for_quote($products_new);     
            }
          ?>
          <!-- EOF 8522 Email For Quote for v1.2 -  Jan 2013 -->               
            </div>
          </div>        </div>
      </div>
    </div>
    <?php
  }
  ?>
  </div>
 
</div>      
	

Any suggestion to fix this problem?

Many thanks!  Lyn
 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...