Forums / General Questions / Remove Add to cart button when product is call for price in Featured Products

Remove Add to cart button when product is call for price in Featured Products

Started by lala_rock on 1 Feb 2012, 7:31 AM · Views: 3,322

Results 1 to 14 of 14
1 Feb 2012, 7:31 AM
#1
lala_rock avatar

lala_rock

New Zenner

Join Date:
Dec 2011
Posts:
41
Plugin Contributions:
0

Remove Add to cart button when product is call for price in Featured Products

Hi fellow zenners, I need your help on this. How can I remove the add to cart button when product is marked as call for price in Featured Products on my index page. What files am I going to modify.

This forum helped me a lot in building my online store.

Thanks in advance.

Cheers,
lala

1 Feb 2012, 11:48 PM
#2
lala_rock avatar

lala_rock

New Zenner

Join Date:
Dec 2011
Posts:
41
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

the call for price is working perfectly on all products listing, new products listings,featured products listing and product listing of every category. I want the featured products on index page to be like that. As of now, it only shows the call for pricing text but still displays the add to cart button. And is it possible to have two defines on includes/languages/english.php for call for price?One for the featured products on index page and the other one is for the rest of the pages. Sorry, I cant provide you url for i am currently working on localhost. Perhaps I can give you screenshots which might help.

Thanks in advance

1 Feb 2012, 11:55 PM
#3
lala_rock avatar

lala_rock

New Zenner

Join Date:
Dec 2011
Posts:
41
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

this is the screenshots of what i want

Attachment #10099

Cheers,
lala

2 Feb 2012, 1:50 AM
#4
lala_rock avatar

lala_rock

New Zenner

Join Date:
Dec 2011
Posts:
41
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

anyone please? sorry for being such a pain. Ive searched the net for long hours now but cant seem to find the solution to my problem.

2 Feb 2012, 11:25 AM
#5
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Remove Add to cart button when product is call for price in Featured Products

We might be able to advise if we could see the site.

2 Feb 2012, 4:10 PM
#6
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

If you go into your define_main_page.php in your define editor in admin and add this at the end..

<style type="text/css"> .buttons {display:none} </style>

...It will get rid of all the add to cart buttons on the front page.

I don't think you will be able to pick and choose easily to remove them, as you have a Template Monster template which has been heavily hacked from the original Zencart template style.

2 Feb 2012, 10:39 PM
#7
lala_rock avatar

lala_rock

New Zenner

Join Date:
Dec 2011
Posts:
41
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

thanks stevesh and dgent for the reply. I just uploaded the site and here is the link

https://spares.cncmachinery.com.au/index.php?main_page=index

I want the add the add to cart button be disable when a product is marked as call for price. How can I achieve that?

Thanks

2 Feb 2012, 11:10 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Remove Add to cart button when product is call for price in Featured Products

Your custom template's featured-products code apparently wasn't designed to support the advanced features such as call-for-price or login-for-price. You'll need to edit that template to add in the business logic needed to accomplish your desired result.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Feb 2012, 11:37 PM
#9
lala_rock avatar

lala_rock

New Zenner

Join Date:
Dec 2011
Posts:
41
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

DrByte would you mind guiding me in doing it? like what file specifically am I going to edit. I was thinking if /includes/modules/my_template/featured_products.php was the right one to modify

3 Feb 2012, 1:58 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Remove Add to cart button when product is call for price in Featured Products

Yes, that's probably the right file to look at, since that file prepares the content which the template file simply displays when it's called.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Feb 2012, 2:31 AM
#11
lala_rock avatar

lala_rock

New Zenner

Join Date:
Dec 2011
Posts:
41
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

what am I going to do next? What am I going to modify? this is the code for my feature_products.php

<?php
/**
 * featured_products module - prepares content for display
 *
 * @package modules
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: featured_products.php 6424 2007-05-31 05:59:21Z ajeh $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}


// initialize vars
$categories_products_id_list = '';
$list_of_products = '';
$featured_products_query = '';
$display_limit = '';

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, pd.products_description
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                           where p.products_id = f.products_id
                           and p.products_id = pd.products_id
                           and p.products_status = 1 and f.status = 1
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
} else {
  // get all products and cPaths in this subcat tree
  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);

  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
    // build products-list string to insert into SQL query
    foreach($productsInCategory as $key => $value) {
      $list_of_products .= $key . ', ';
    }
    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
    $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, pd.products_description
                                from (" . TABLE_PRODUCTS . " p
                                left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                                left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id)
                                where p.products_id = f.products_id
                                and p.products_id = pd.products_id
                                and p.products_status = 1 and f.status = 1
                                and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                and p.products_id in (" . $list_of_products . ")";
  }
}
if ($featured_products_query != '') $featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);

$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';

$num_products_count = ($featured_products_query == '') ? 0 : $featured_products->RecordCount();

// show only when 1 or more
if ($num_products_count > 0) {
  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS == 0) {
    $col_width = floor(100/$num_products_count);
  } else {
    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS);
  }
  while (!$featured_products->EOF) {
  
    if (!isset($productsInCategory[$featured_products->fields['products_id']])) $productsInCategory[$featured_products->fields['products_id']] = zen_get_generated_category_path_rev($featured_products->fields['master_categories_id']);
  

    $products_img = (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a>');
    
	$products_name = '<a class="name" href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a>';

//$productsIncategory= '<a class="name" href="' . zen_href_link(zen_get_info_page($featured_products->fields
//['product_id']), 'cPath=' . $productsInCategory[$featured_products->fields['master_categories_id']] . '&products_id=' . 
//$featured_products->fields['master_categories_id']) . '">' . $featured_products->fields['master_categories_id'] . '</a>';


	$products_desc = substr(strip_tags($featured_products->fields['products_description']), 0, 35) . '...';
	
	$products_price = '<strong>' . zen_get_products_display_price($featured_products->fields['products_id']) . '</strong>';
	
	$products_######## = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_GOTO_PROD_DETAILS, BUTTON_GOTO_PROD_DETAILS_ALT) . '</a>';
	
	$products_butt2 = '<a href="' . zen_href_link(FILENAME_PRODUCTS_NEW, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields["products_id"]) . '">' . zen_image_button(BUTTON_IMAGE_ADD_TO_CART, BUTTON_IN_CART_ALT) . '</a>';
	
	$img_col_w = IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH + 17;

	if (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS > 1 && $num_products_count > 1) {
	
		if ($col > 0 && $col < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS) {
			$vLine = 'vLine';
		} else {
			$vLine = '';
		}
		if ($row > 0) {
			$hLine = 'hLine';
		}else{
			$hLine = '';
		}
	
    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent '.$vLine.' back"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => 

// added table to align texts

			'<div class="product-col '.$hLine.'">
				<div class="img" width="24px" >
					' . $products_img . '
				</div>
				<div class="product-info" width="24px">

			        <table>
				<tr height="90px">
				<td  height="54px">
					' . $products_name .'</br>'. '





<a href= "index.php?main_page=index&cPath=1_21_66' .  zen_href_link(zen_get_info_page($featured_products->fields['products_id']),  'cPath=' .  $productsInCategory[$featured_products->fields['products_id']] .  '&linkProductsName=' . $featured_products->fields['products_id']) .  '"><font size="-2" color="#898787">' . zen_get_category_name($featured_products->fields['master_categories_id'], $_SESSION['languages_id']) . $featured_products->fields[''] . '</font></a>






</td>

				</tr>
				</table>
					<div class="wrapper" width="24px">
						<div class="price">
                                    <table>
				<tr>
				<td  height="54px">
       
                                    '.$products_price.'
                            </td>
				</tr>
				</table>

                                                <table>
                                                <tr align="center">
                                                <td align="center" height="30px">

                                                <div class="buttons">'.$products_butt2 .'</td><td align="center">' . $products_########.'</div>
                                                </td>
                                                </tr>
                                                </table>
                                        </div>
					</div>
				</div>
			</div>'
					
			);
	
	} else {

    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => 
	
			'<div class="product-col '.$hLine.'">
				<div class="img" width="24px" style="position:relative; left:-270px;">
					' . $products_img . '
				</div>
				<div class="product-info">
					' . $products_name . '</br>'. '





<a href= "index.php?main_page=index&cPath=1_21_66' .  zen_href_link(zen_get_info_page($featured_products->fields['products_id']),  'cPath=' .  $productsInCategory[$featured_products->fields['products_id']] .  '&linkProductsName=' . $featured_products->fields['products_id']) .  '"><font size="-2" color="#898787">' . zen_get_category_name($featured_products->fields['master_categories_id'], $_SESSION['languages_id']) . $featured_products->fields[''] . '</font></a>









					<div class="wrapper">
						<div class="price">'.$products_price.'</div>
						<div class="buttons">'.$products_butt2 . $products_########.'</div>
					</div>
				</div>
			</div>'
			
			);

	}

    $col ++;
    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS - 1)) {
      $col = 0;
      $row ++;
    }
    $featured_products->MoveNextRandom();
  }

  if ($featured_products->RecordCount() > 0) {
  
// DO NOT DISPLAY HEADING AT HOME PAGE
  	//if (!$this_is_home_page) {




// -----------------------------------


    if (isset($new_products_category_id) && $new_products_category_id !=0) {
      $category_title = zen_get_categories_name((int)$new_products_category_id);
      $title = '
	  <h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title != '' ? ' - ' . $category_title : '') . '</h2>
	  '; 
    } else {
      $title = '
	  <h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . '</h2>
	  ';
    }
	
// DO NOT DISPLAY HEADING AT HOME PAGE
	//}
// -----------------------------------
	
    $zc_show_featured = true;
  }
}
?>
3 Feb 2012, 4:55 AM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Remove Add to cart button when product is call for price in Featured Products

I suppose you could try the following:

Line 88 says this:```
$products_butt2 = '<a href="' . ......

On line 89 (which is blank) add this new line:```
    if (stristr($products_price, 'call for price')) $products_butt2 = '';

That basically just removes the unintelligent Add To Cart button that your template author stuffed into the code.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Feb 2012, 5:34 AM
#13
lala_rock avatar

lala_rock

New Zenner

Join Date:
Dec 2011
Posts:
41
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

worked perfectly! :clap:

Thanks so much DrByte

21 Feb 2013, 2:52 PM
#14
chipsmunk avatar

chipsmunk

New Zenner

Join Date:
Feb 2013
Posts:
1
Plugin Contributions:
0

Re: Remove Add to cart button when product is call for price in Featured Products

i try to changes as guideline but failed . here my script

<?php
/**
 * featured_products module - prepares content for display
 *
 * @package modules
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: featured_products.php 6424 2007-05-31 05:59:21Z ajeh $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}

// initialize vars
$categories_products_id_list = '';
$list_of_products = '';
$featured_products_query = '';
$display_limit = '';

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                           where p.products_id = f.products_id
                           and p.products_id = pd.products_id
                           and p.products_status = 1 and f.status = 1
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
} else {
  // get all products and cPaths in this subcat tree
  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);

  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
    // build products-list string to insert into SQL query
    foreach($productsInCategory as $key => $value) {
      $list_of_products .= $key . ', ';
    }
    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
    $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id
                                from (" . TABLE_PRODUCTS . " p
                                left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                                left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id)
                                where p.products_id = f.products_id
                                and p.products_id = pd.products_id
                                and p.products_status = 1 and f.status = 1
                                and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                and p.products_id in (" . $list_of_products . ")";
  }
}
if ($featured_products_query != '') $featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);

$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';

$num_products_count = ($featured_products_query == '') ? 0 : $featured_products->RecordCount();

// show only when 1 or more
if ($num_products_count > 0) {
  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS == 0) {
    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS)- 1.4;
  } else {
    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS) - 1.4;
  }
  while (!$featured_products->EOF) {
    $products_price = zen_get_products_display_price($featured_products->fields['products_id']);
    if (!isset($productsInCategory[$featured_products->fields['products_id']])) $productsInCategory[$featured_products->fields['products_id']] = zen_get_generated_category_path_rev($featured_products->fields['master_categories_id']);

	$zen4me_prod_title = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . stripslashes(zen_trunc_string($featured_products->fields['products_name'], 20)) . '</a>';
	$zen4me_more_details = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_GOTO_PROD_DETAILS, BUTTON_GOTO_PROD_DETAILS_ALT) . '</a>';
	$zen4me_buy_now = '<a href="' . zen_href_link(FILENAME_PRODUCTS_NEW, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';


    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured" id="back"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => 
		'<ul><li>
<div class="zm01_container">
	<div id="zm01_header">' 
	. $zen4me_prod_title . '<br /><br />

	<div class="zenImage_featured">
	<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">
	<span></span>' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a>
	</div>
	</div>
	<div class="zm01_footer">
	' .
	$products_price . '
	<br />' .
	$zen4me_more_details . '
	<br />' . 
	$zen4me_buy_now . '
	</div>
</div>	
		</li></ul>');	
	
	

    $col ++;
    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS - 1)) {
      $col = 0;
      $row ++;
    }
    $featured_products->MoveNextRandom();
  }

  if ($featured_products->RecordCount() > 0) {
    if (isset($new_products_category_id) && $new_products_category_id !=0) {
      $category_title = zen_get_categories_name((int)$new_products_category_id);
      $title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title != '' ? ' - ' . $category_title : '') . '</h2>';
    } else {
      $title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . '</h2>';
    }
    $zc_show_featured = true;
  }
}
?>