Page 1 of 2

How to hide product price and add to cart?

Posted: Tue Apr 17, 2012 4:32 pm
by malinga91
Dear All,

I want to hide price and add to cart option from my open cart when product price not insert. If i don't insert product price that product price will show " $ 0.00 ". How to do this? I haven't huge programming knowledge. But, i can copy & paste. ;D please help me.

Thank you all.

Re: How to hide product price and add to cart?

Posted: Tue Apr 17, 2012 6:42 pm
by malinga91
still waiting for a reply. :(

Re: How to hide product price and add to cart?

Posted: Tue Apr 17, 2012 7:10 pm
by dbassa
Hi,

Try to locate:

Code: Select all

<?php if ($price) { ?>
in catalog/view/theme/yourtheme/template/product/product.tpl

Replace it for:

Code: Select all

<?php if ($price>0) { ?>
Try to locate:

Code: Select all

        <div><?php echo $text_qty; ?>
          <input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
          <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
          &nbsp;<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" />
          </div>
Replace it for:

Code: Select all

<?php if ($price>0) { ?>
        <div><?php echo $text_qty; ?>
          <input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
          <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
          &nbsp;<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" />
          </div>
<?php } ?>

Re: How to hide product price and add to cart?

Posted: Tue Apr 17, 2012 7:19 pm
by Qphoria
As another alternative, you could just add this to the bottom of your stylesheet.css file:

Code: Select all

.price { display:none; }
.cart { display:none; }

Re: How to hide product price and add to cart?

Posted: Tue Apr 17, 2012 7:48 pm
by malinga91
Thank you very much dbassa and Qphoria. I'll try and let you know what happened to me.... :D

Re: How to hide product price and add to cart?

Posted: Wed Apr 18, 2012 11:12 am
by malinga91
Qphoria wrote:As another alternative, you could just add this to the bottom of your stylesheet.css file:

Code: Select all

.price { display:none; }
.cart { display:none; }
Dear Qphoria,

Can i hide quantity box as well using this...?

Re: How to hide product price and add to cart?

Posted: Wed Apr 18, 2012 11:34 am
by malinga91
Dear dbassa,

I have used another template for my cart. I tried to locate code and replaced. But i didn't get proper solution. I have pasted my product.tpl file. Can you correct it and let me know what are code should be corrected.?

Code: Select all

<?php echo $header; ?>
<div id="content">
  <ul class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
	    <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
    <?php } ?>
  </ul>
  <div class="clear"></div>
  
<?php echo $column_left; ?>
<?php echo $column_right; ?>

  <div class="product-info">
    <ul id="tab" class="tabs">
        	<li><a href="javascript:void(0);" class="active" rel="details">Details</a></li>
            <?php if ($products) { ?>
            	<li><a href="javascript:void(0);" rel="related"><?php echo $tab_related; ?> (<?php echo count($products); ?>)</a></li>
        	<?php } ?>
			<?php if ($attribute_groups) { ?>
                <li><a href="javascript:void(0);" rel="attributes"><?php echo $tab_attribute; ?></a></li>
            <?php } ?>
            <?php if ($review_status) { ?>
                <li><a href="javascript:void(0);" rel="reviews"><?php echo $tab_review; ?></a></li>
            <?php } ?>
    </ul>
    <div class="clear"></div>
    <div class="left <?php if(!$images){ echo "noThumb"; } ?>">
    <?php if ($thumb || $images) : //Product Image ?>
         <div class="mainImg">
            <?php if ($thumb) : ?>
                    <a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="colorbox" rel="colorbox"><img src=" <?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" /></a>
            <?php endif; ?>
         </div>
   	<?php endif; ?>
    <div class="clear"></div>
    <?php if ($images) : //Product Thumbnails ?>
    <div class="thumbs">
            <div class="thumbWrap">
                    <?php foreach ($images as $image) : ?>
                        <div><a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="colorbox" rel="colorbox"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a></div>
                    <?php endforeach; ?>   
            </div>
            <?php if(count($images)>2) : ?>
                <ul class="prevNext">
                    <li><a href="javascript:void(0);" class="prev">prev</a></li>
                    <li><a href="javascript:void(0);" class="next">next</a></li>
                </ul>
            <?php endif; ?>
    </div>
    <?php endif; ?>
     </div>
     
<div class="right">       
	<div class="innerRight">
        <div class="tab details">
        <div class="infoRight">
        	<ul class="infoList">
            	<li><span><?php echo $text_stock; ?></span> <strong><?php echo $stock; ?></strong></li>
				<?php if ($manufacturer) { ?>
                    <li><span><?php echo $text_manufacturer; ?></span> <a href="<?php echo $manufacturers; ?>"><?php echo $manufacturer; ?></a></li>
                <?php } ?>
                	<li><span><?php echo $text_model; ?></span> <strong><?php echo $model; ?></strong></li>
               	 	<li><span><?php echo $text_reward; ?></span> <strong><?php echo $reward; ?></strong></li>
            </ul>
            <!-- Wishlist/Compare -->
            <ul class="addwc">
                <li class="wishlist"><span>+</span> <a onclick="addToWishList('<?php echo $product_id; ?>');"><?php echo $button_wishlist; ?></a></li>
                <li class="compare"><span>+</span> <a onclick="addToCompare('<?php echo $product_id; ?>');" data-reveal-id="notification"><?php echo $button_compare; ?></a></li>
                <!-- AddThis Button BEGIN -->
                <li class="socialLinks tweet"><a class="addthis_button_tweet"></a></li>
                <li class="socialLinks"><a class="addthis_button_google_plusone" g:plusone:size="medium"></a></li>
                <li class="socialLinks"><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a></li>
                <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4ead658750c660a2"></script>
            </ul>
        </div>
        <div class="prodDesc">
            <h1><?php echo $heading_title; //Product Title ?></h1>
            <?php if ($review_status) : //Reviews & Ratings ?>
             	<div class="stars">
                 	<img src="catalog/view/theme/herbal/image/stars-<?php echo $rating; ?>.png" alt="<?php echo $reviews; ?>" />            
                 	<a onclick="$('a[href=\'#tab\']').trigger('click');" class="reviews" rel="reviews"><?php echo $reviews; ?></a>
                </div>
             <?php endif; ?>
             <div class="description"><?php echo $description; //Product Description ?></div>
             	<div class="pPrice">
					  <?php if ($price) : //Product Price ?>
                            <?php if (!$special) : ?>
                                   <p> <span class="normal"><?php echo $text_price; ?></span> 
                                   <span class="price price-new"><?php echo $price; ?></span></p>
                            <?php else: ?>
                                   <p><?php echo $text_price; ?> <span class="price-old"><?php echo $price; ?></span> 
                                    <span class="price-new"><?php echo $special; ?></span></p>
                            <?php endif; ?>
                      <?php endif; ?>   
                 </div>   
            
					<?php if ($discounts) : //Product Discounts ?>
                    <div class="prod-discount">
                            <p><strong><?php echo $this->language->get('prod_discount'); //english.php file ?></strong></p>
                            <ul>
                                  <?php foreach ($discounts as $discount) : ?>
                                    <li><span><?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?></span></li>
                                  <?php endforeach; ?>
                            </ul>
                   </div>
                   <?php endif; ?>
                   
                 
              <div class="clear"></div>
           </div>
      
	  <?php if ($options) : ?>
          <div class="options">
          	<div class="opFields">
				<?php include("includes/options.tpl"); //Product Options ?>
            </div>
            <div class="addCartBox">
            	<?php if ($minimum > 1) : ?>
                    <div class="minimum"><p><?php echo $text_minimum; ?></p></div>
                <?php endif; ?>
                <div class="qty">                  
                          <strong><?php echo $text_qty; ?></strong>
                          	<input id="qty" type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />     
                            <a class="qtyBtn increase" href="javascript:void(0);">+</a>  
                            <a class="qtyBtn decrease" href="javascript:void(0);">-</a> 
                          	<input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
                        <div class="clear"></div>
                </div>
                <div class="addTo">
                     <div class="cart">
                   	<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" />
                     </div>
                </div>
             </div>
             <div class="clear"></div>
          </div>
      <?php else: ?>
            <div class="addCartBox innerAddBox">
            <?php if ($minimum > 1) : ?>
                <div class="minimum"><p><?php echo $text_minimum; ?></p></div>
            <?php endif; ?>
            <div class="qty">                  
                      <strong><?php echo $text_qty; ?></strong>
                        <input id="qty" type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />     
                        <a class="qtyBtn increase" href="javascript:void(0);">+</a>  
                        <a class="qtyBtn decrease" href="javascript:void(0);">-</a> 
                        <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
                    <div class="clear"></div>
            </div>
            <div class="addTo">
                 <div class="cart">
                   	<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" />
                 </div>
            </div>
            </div>
      <?php endif; ?>
    </div>
    </div><!-- End Product Inner -->
    <div class="clear"></div>
    	<?php if ($products) { ?>
              <div class="tab related">
              	<p class="tabTitle"><?php echo $tab_related; ?></p>
                <?php include("includes/related.tpl"); ?>
                <div class="clear"></div>
              </div>
  	 	<?php } ?>
		<?php if ($attribute_groups) { ?>
              <div class="tab attributes">
              	<p class="tabTitle"><?php echo $tab_attribute; ?></p>
                <?php include("includes/attributes.tpl"); ?>
              </div>
        <?php } ?>
		<?php if ($review_status) { ?>
              <div class="tab reviews">
              	<p class="tabTitle"><?php echo $tab_review; ?></p>
                <?php include("review_form.tpl"); ?>
                <div class="clear"></div>
              </div>
        <?php } ?>
        
	</div><!-- End Product Info -->
    <div class="clear"></div>
    </div>
    <div class="clear"></div>
</div>

<script type="text/javascript"><!--
$('.colorbox').colorbox({
	overlayClose: true,
	opacity: 0.5
});
//--></script> 
<script type="text/javascript"><!--
$('#button-cart').bind('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			
			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
					}
				}
			} 
			
			if (json['success']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
					
				$('#cart-total').html(json['total']);
				
				var notify = $('#notification').html();
				$.blockUI({ message: $(notify) });
				$('.blockOverlay').click(function(){
					$.unblockUI();
				});
			}	
		}
	});
});
//--></script>
<?php if ($options) { ?>
<script type="text/javascript" src="catalog/view/javascript/jquery/ajaxupload.js"></script>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'file') { ?>
<script type="text/javascript"><!--
new AjaxUpload('#button-option-<?php echo $option['product_option_id']; ?>', {
	action: 'index.php?route=product/product/upload',
	name: 'file',
	autoSubmit: true,
	responseType: 'json',
	onSubmit: function(file, extension) {
		$('#button-option-<?php echo $option['product_option_id']; ?>').after('<img src="catalog/view/theme/default/image/loading.gif" class="loading" style="padding-left: 5px;" />');
	},
	onComplete: function(file, json) {
		$('.error').remove();
		
		if (json.success) {
			alert(json.success);
			
			$('input[name=\'option[<?php echo $option['product_option_id']; ?>]\']').attr('value', json.file);
		}
		
		if (json.error) {
			$('#option-<?php echo $option['product_option_id']; ?>').after('<span class="error">' + json.error + '</span>');
		}
		
		$('.loading').remove();	
	}
});
//--></script>
<?php } ?>
<?php } ?>
<?php } ?>
<script type="text/javascript"><!--
$('#review .pagination a').live('click', function() {
	$('#review').slideUp('slow');
		
	$('#review').load(this.href);
	
	$('#review').slideDown('slow');
	
	return false;
});			

$('#review').load('index.php?route=product/product/review&product_id=<?php echo $product_id; ?>');

$('#button-review').bind('click', function() {
	$.ajax({
		url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
		type: 'post',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-review').attr('disabled', true);
			$('#review-title').after('<div class="attention"><img src="catalog/view/theme/default/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');
		},
		complete: function() {
			$('#button-review').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(data) {
			if (data.error) {
				$('#review-title').after('<div class="warning">' + data.error + '</div>');
			}
			
			if (data.success) {
				$('#review-title').after('<div class="success">' + data.success + '</div>');
								
				$('input[name=\'name\']').val('');
				$('textarea[name=\'text\']').val('');
				$('input[name=\'rating\']:checked').attr('checked', '');
				$('input[name=\'captcha\']').val('');
			}
		}
	});
});
//--></script> 
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-timepicker-addon.js"></script> 
<script type="text/javascript"><!--
if ($.browser.msie && $.browser.version == 6) {
	$('.date, .datetime, .time').bgIframe();
}

$('.date').datepicker({dateFormat: 'yy-mm-dd'});
$('.datetime').datetimepicker({
	dateFormat: 'yy-mm-dd',
	timeFormat: 'h:m'
});
$('.time').timepicker({timeFormat: 'h:m'});
//--></script> 
<?php echo $footer; ?>

Thank you Very much.

Re: How to hide product price and add to cart?

Posted: Wed Apr 18, 2012 4:13 pm
by dbassa
Yes malinga91, let me a bit of time to finish an extension I am doing and I check your code.

Daniel

Re: How to hide product price and add to cart?

Posted: Thu Apr 19, 2012 2:18 pm
by malinga91
dbassa wrote:Yes malinga91, let me a bit of time to finish an extension I am doing and I check your code.

Daniel
Thank you Daniel,

I' tested on default template product.tpl file. When i replaced your code, prices are hide with already entered. My client need is , He need to run advertisement through product. When we insert advertisement we don't need to add prices. If we don't enter prices, price is showed bottom of the ad. (like this : $ 0.00) I want to hide it and cart option. not all prices and not all cart options. Can you do it easily? If you can give solution it's great great help. I have attached a dummy image for my need.

Thank you.
Best regards.
Suraj Malinga

Re: How to hide product price and add to cart?

Posted: Fri Apr 20, 2012 4:13 am
by dbassa
Hi malinga,

You have got a different template:

Try to locate this line:

Code: Select all

<?php if ($price) : //Product Price ?>
And change it for:

Code: Select all

<?php if ($price>0) : //Product Price ?>
All you add after the above line is going to be seen only when the product is greater than 0.

Remember you must do that in product.tpl, category.tpl, search.tpl, manufacturer.tpl and so on.

Best Regards,

Re: How to hide product price and add to cart?

Posted: Mon Apr 23, 2012 11:46 am
by malinga91
Dear Devian,

This option also not working. When i apply $price>0 all prices are hidden.
dbassa wrote:Hi malinga,

You have got a different template:

Try to locate this line:

Code: Select all

<?php if ($price) : //Product Price ?>
And change it for:

Code: Select all

<?php if ($price>0) : //Product Price ?>
All you add after the above line is going to be seen only when the product is greater than 0.

Remember you must do that in product.tpl, category.tpl, search.tpl, manufacturer.tpl and so on.

Best Regards,
I have attached my full template. Can you check it and let me know.? I'm appreciate you helps.

Thank you
Best regards

Re: How to hide product price and add to cart?

Posted: Tue Apr 24, 2012 3:33 pm
by dbassa
Hi Maligna,

Try this please: <?php if (!empty($price)) : //Product Price ?>

Re: How to hide product price and add to cart?

Posted: Tue Apr 24, 2012 3:40 pm
by malinga91
Dear Daniel,

Thank you so much. I'll try and let you know what happened to me. I'll waiting for a reply from yesterday.... :D

Thank you.

Re: How to hide product price and add to cart?

Posted: Tue Apr 24, 2012 4:35 pm
by dbassa
:)

Re: How to hide product price and add to cart?

Posted: Tue Apr 24, 2012 5:58 pm
by malinga91
Hi davian,
dbassa wrote:Hi Maligna,

Try this please: <?php if (!empty($price)) : //Product Price ?>
This option also not working. do you know how to generate "$0.00"? if we delete this, then it will not appear. am i correct?

Thank you

Re: How to hide product price and add to cart?

Posted: Tue Apr 24, 2012 6:29 pm
by dbassa
We will try another thing. Let me see.

Re: How to hide product price and add to cart?

Posted: Wed Apr 25, 2012 6:52 pm
by malinga91
Hi Davian,

Can we do something do this code.?

upload\admin\controller\catalog\product.php

if (isset($this->request->post['price'])) {
$this->data['price'] = $this->request->post['price'];
} elseif (!empty($product_info)) {
$this->data['price'] = $product_info['price'];
} else {
$this->data['price'] = '';
}


or...

..../product.tpl

<?php if ($price) : //Product Price ?>
<?php if (!$special) : ?>
<p> <span class="normal"><?php echo $text_price; ?></span>
<span class="price price-new"><?php echo $price; ?></span></p>
<?php else: ?>
<p><?php echo $text_price; ?> <span class="price-old"><?php echo $price; ?></span>
<span class="price-new"><?php echo $special; ?></span></p>
<?php endif; ?>
<?php endif; ?>

can we apply condition to <?php echo $price; ?>?

Re: How to hide product price and add to cart?

Posted: Mon Apr 30, 2012 2:52 pm
by malinga91
Still waiting for a reply :(

Re: How to hide product price and add to cart?

Posted: Tue May 01, 2012 6:35 pm
by dbassa
Hi malinga,

Try this please:

Code: Select all

<?php if (!empty($price)) : //Product Price ?>
And you could also add this line of code, just to know what is the price value:

Code: Select all

echo $price;
You should see a little message on your screen, it would help us.

Regards,

Re: How to hide product price and add to cart?

Posted: Thu May 03, 2012 2:16 pm
by malinga91
<div class="pPrice">
<?php if (!empty($price)) : //Product Price ?>
<?php if (!$special) : ?>
<p> <span class="normal"><?php echo $text_price; ?></span>
<span class="price price-new"><?php if (!empty($price)) echo $price; ?></span></p>
<?php else: ?>
<p><?php echo $text_price; ?> <span class="price-old"><?php echo $price; ?></span>
<span class="price-new"><?php echo $special; ?></span></p>
<?php endif; ?>
<?php endif; ?>
</div>

I did like this.. But it's not working.... :(