Zen Cart Logo
Forums / General Questions / Disable add to cart button in specials sidebox

Disable add to cart button in specials sidebox

Views: 862

Results 1 to 4 of 4
6 Feb 2012, 12:59 AM
#1
lala_rock avatar

lala_rock

New Zenner

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

Disable add to cart button in specials sidebox

Hi there! just want to ask how will I disable the add to cart button when product is marked as call for price in specials sidebox. I had this kind of issue but its for featured products on homepage. DrByte helped me out on this. Now, Im trying to use his codes for the said sidebox but what I got was the add to cart button doesnt show even when the product has price and not marked as call for price.

Here is the link to my site:

https://spares.cncmachinery.com.au/

here is the code of my tpl_specials.php under includes/templates/my_template/sideboxes/

<?php
/**
 * tpl_specials.php
 *
 * @package templateSystem
 * @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: tpl_specials.php 6128 2007-04-08 04:53:32Z birdbrain $
 */
  $content = "";
  $specials_box_counter = 0;
  while (!$random_specials_sidebox_product->EOF) {
    $specials_box_counter++;
    $specials_box_price = zen_get_products_display_price($random_specials_sidebox_product->fields['products_id']);
    $content .= '<div class="sideBoxContent centeredContent" style="background-color:#DEDCDC; height:312px;" >';
    $content .= '<div class="img" style="background-color:#DEDCDC; height:150px; position:relative; top:-12px;"><a href="' . zen_href_link(zen_get_info_page($random_specials_sidebox_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_specials_sidebox_product->fields["master_categories_id"]) . '&products_id=' . $random_specials_sidebox_product->fields["products_id"]) . '">' . zen_image(DIR_WS_IMAGES . $random_specials_sidebox_product->fields['products_image'], $random_specials_sidebox_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></div>';

$content .= '<div class="box-product-info">';
	
    $content .= '<a class="name" href="' . zen_href_link(zen_get_info_page($random_specials_sidebox_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_specials_sidebox_product->fields["master_categories_id"]) . '&products_id=' . $random_specials_sidebox_product->fields["products_id"]) . '">' . $random_specials_sidebox_product->fields['products_name'] . '</a>';
    $content .= '<div class="price">' . $specials_box_price . '</div>';
	
	$content .= '<div class="buttons">';
	
	$content_button .= '<a href="' . zen_href_link(FILENAME_PRODUCTS_NEW, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $random_specials_sidebox_product->fields["products_id"]) . '">' . zen_image_button(BUTTON_IMAGE_ADD_TO_CART2, BUTTON_IN_CART_ALT) . '</a>';



if (stristr($specials_box_price, 'call for price')) $content_button = '';

	
	$content .= '<a href="' . zen_href_link(zen_get_info_page($random_specials_sidebox_product->fields["products_id"]), 'cPath=' . zen_get_generated_category_path_rev($random_specials_sidebox_product->fields["master_categories_id"]) . '&products_id=' . $random_specials_sidebox_product->fields["products_id"]) . '">' . zen_image_button(BUTTON_IMAGE_GOTO_PROD_DETAILS2, BUTTON_GOTO_PROD_DETAILS_ALT) . '</a>';
	


$img_col_w = IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH + 17;






	$content .= '</div>';
	
	$content .= '</div>';
	
    $content .= '</div>';
    $random_specials_sidebox_product->MoveNextRandom();
  }
?>

the codes in red are those that I modify. Kindly help.
Thanks

6 Feb 2012, 6:00 AM
#2
lala_rock avatar

lala_rock

New Zenner

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

Re: Disable add to cart button in specials sidebox

Ive read this "You want to load all of your content into the $content variable."

If thats the case, how am I going to insert this piece of code?

if (stristr($products_price, 'call for price')) $products_butt2 = '';

I tried putting $content before the code above which reads

$content .= if (stristr($products_price, 'call for price')) $products_butt2 = '';
``` but it only shows a blank page.Please help.Im trying my best to understand php. 

Thanks
6 Feb 2012, 6:22 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Disable add to cart button in specials sidebox

	
if (stristr($specials_box_price, 'call for price'))
$content .= '<a href="' . zen_href_link(FILENAME_PRODUCTS_NEW, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $random_specials_sidebox_product->fields["products_id"]) . '">' . zen_image_button(BUTTON_IMAGE_ADD_TO_CART2, BUTTON_IN_CART_ALT) . '</a>';
6 Feb 2012, 7:01 AM
#4
lala_rock avatar

lala_rock

New Zenner

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

Re: Disable add to cart button in specials sidebox

yay! thank u again DrByte :)