Post by rivercottage » Sun Feb 05, 2012 7:30 pm

Hiya guys

Ive been through all the posts I can find, bascially on my product.tpl I would like to display 'unavailable' if the price=0

I found the post regarding changing the currency file, but this also causes an empty checkout to display unavailable.

Im trying this line of code to no avail, any help most appreciated


<?php if ((float)str_replace('£', '', $price) == 0) { echo "Unavailable"; } else { ?>show the price <?php }?>


thankyou

Newbie

Posts

Joined
Tue May 31, 2011 10:02 pm

Post by MarketInSG » Mon Feb 06, 2012 7:00 pm

1. Edit catalog/view/theme/YOUR-THEME/template/product/product.tpl
2. Find (line 37)

Code: Select all

        <?php echo $price; ?>
replace with

Code: Select all

		<?php if($price == "$0.00") { echo "Unavailable"; } else { echo $price;} ?>
BUT do note the '$' sign. Change accordingly to your currency. If you allow a change of currency on your website, then it will be a little more complicated.


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by GoGo OpenCart » Tue Feb 07, 2012 5:59 am

Or try those two modules:

http://www.opencart.com/index.php?route ... on_id=4067

http://www.opencart.com/index.php?route ... on_id=4139

If you got the idea, but want some modifications on those modules, feel free to PM ;)

See all my extensions: https://www.opencart.com/index.php?rout ... 20OpenCart


User avatar
Active Member

Posts

Joined
Mon Nov 14, 2011 11:30 pm

Post by rwalker » Thu Jan 24, 2013 4:42 am

MarketInSG wrote:1. Edit catalog/view/theme/YOUR-THEME/template/product/product.tpl
2. Find (line 37)

Code: Select all

        <?php echo $price; ?>
replace with

Code: Select all

		<?php if($price == "$0.00") { echo "Unavailable"; } else { echo $price;} ?>
BUT do note the '$' sign. Change accordingly to your currency. If you allow a change of currency on your website, then it will be a little more complicated.
Hi I am trying to make this into a range of prices.

I have tried this with no luck:

Code: Select all

<?php if($price == "$99.00-$999.00") { echo "Unavailable"; } else { echo $price;} ?>

Discount Golf Clubs and Golf Equipment - Powered by Opencart


New member

Posts

Joined
Fri Jul 01, 2011 8:14 am

Post by MarketInSG » Thu Jan 24, 2013 8:04 am

use greater than or less than signs

Code: Select all

<?php if($price > 99.00 && $price < 999.00) { echo "Unavailable"; } else { echo $price;} ?>


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by rwalker » Fri Jan 25, 2013 6:30 am

Thank you, that did it.

I tried that once with the $ and locked myself out of the admin with an error.

Discount Golf Clubs and Golf Equipment - Powered by Opencart


New member

Posts

Joined
Fri Jul 01, 2011 8:14 am

Post by johnnynnhoj » Fri Jan 25, 2013 2:40 pm

I got this working on the product pages. Is there any way to do the same thing on the category listings?

Newbie

Posts

Joined
Mon Jan 14, 2013 11:43 am

Post by johnnynnhoj » Fri Jan 25, 2013 2:51 pm

Actually I think I figured it out. In /template/product/category.tpl, I changed

Code: Select all

<?php if ($product['price']) { ?>
      <div class="price">
        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
        <?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
	
to this

Code: Select all

<?php if ($product['price']) { ?>
      <div class="price">
        
		<?php if ($product['price'] == "$0.00") { ?>
		<?php echo "Customizable"; ?>
		<?php } else { ?>
		
		<?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
        <?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
		
		<?php } ?>

Newbie

Posts

Joined
Mon Jan 14, 2013 11:43 am

Post by RideTheWave » Sun Jun 04, 2017 1:13 pm

johnnynnhoj wrote:
Fri Jan 25, 2013 2:51 pm
Actually I think I figured it out. In /template/product/category.tpl, I changed

Code: Select all

<?php if ($product['price']) { ?>
      <div class="price">
        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
        <?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
	
to this

Code: Select all

<?php if ($product['price']) { ?>
      <div class="price">
        
		<?php if ($product['price'] == "$0.00") { ?>
		<?php echo "Customizable"; ?>
		<?php } else { ?>
		
		<?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
        <?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
		
		<?php } ?>
Hi, the code you edited works in the Category page but only in the List View, not in the Grid View. Do you know how to further edit the category page to show customizable text (or no text at all) if the product price is $0.00 for both List View and Grid View?

New member

Posts

Joined
Fri May 19, 2017 8:29 am

Post by goodshop » Wed Jul 19, 2017 1:37 pm

Marketln sg. i used your way to hide price and it does work fine on product page. but it can not hide price on main category page. how can u go about it.
i used it on product.tpl please suggest as per below

<?php if($price == "$0.00") { echo "Unavailable"; } else { echo $price;} ?>

Newbie

Posts

Joined
Sat Jul 09, 2016 6:53 pm

Post by MarketInSG » Wed Jul 19, 2017 4:57 pm

goodshop wrote:
Wed Jul 19, 2017 1:37 pm
Marketln sg. i used your way to hide price and it does work fine on product page. but it can not hide price on main category page. how can u go about it.
i used it on product.tpl please suggest as per below

<?php if($price == "$0.00") { echo "Unavailable"; } else { echo $price;} ?>
category page, use $product['price'] instead of $price


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by pickettoilfield » Thu Sep 07, 2017 3:22 am

is there a code modification that I can make in code manager in OC 2.0.3.1 so that I can type Call for Price in the price area or SOLD in the price area on the product page and it show Call for Price for the price or SOLD for the price in all areas?


Posts

Joined
Thu Sep 07, 2017 2:46 am
Who is online

Users browsing this forum: hoatinh and 33 guests