Hi Davian,
This is the code which i have edited. Is this wrong.?
If you can just edit this code and send me... It's a great help for me.
Thank you.
Take care.
This is the code which i have edited. Is this wrong.?
Code: Select all
<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>
Thank you.
Take care.
Please maligna, as I told you before, try to add this line of code: (after this:)
And tell us what is the value for price when you enter to the page.
Thanks,
Code: Select all
echo $price;
Code: Select all
<div class="pPrice">
Thanks,
Thats because $price is a STRING usually looking like "$0.00" , which wont work because of the dollar symbol being there. So you use REGEX to grab only numbers and decimal points, then compare that. This is what your if line should look like.
You are going to need to do a find and replace on that if statement to make life easy since you will need to edit most of the files in catalog/view/theme/YOURTEMPLATE/product as well as catalog/view/theme/YOURTEMPLATE/module.
Your welcome...
You are going to need to do a find and replace on that if statement to make life easy since you will need to edit most of the files in catalog/view/theme/YOURTEMPLATE/product as well as catalog/view/theme/YOURTEMPLATE/module.
Your welcome...
Code: Select all
if (preg_replace('/[^0-9.]/', '', $price) > 0)
This is the solution! (Two years laters still running. Don't forget change de code in others .tpl archive (category, search and others!!)hoyle.a wrote:Thats because $price is a STRING usually looking like "$0.00" , which wont work because of the dollar symbol being there. So you use REGEX to grab only numbers and decimal points, then compare that. This is what your if line should look like.
You are going to need to do a find and replace on that if statement to make life easy since you will need to edit most of the files in catalog/view/theme/YOURTEMPLATE/product as well as catalog/view/theme/YOURTEMPLATE/module.
Your welcome...
Code: Select all
if (preg_replace('/[^0-9.]/', '', $price) > 0)
Thank you a lot!!

I've tried the above code by doing this in product.tpl:
and received the following error message:
Parse error: syntax error, unexpected $end...on line 541
I then changed the code to this:
And the prices still displayed (those that are set to zero price)
Then I did this:
And received an error message:
Parse error: syntax error, unexpected '<' ... in line 40
Can someone please give me the correct syntax so I can have products with zero prices remove the prices being displayed?
Thank you.
Code: Select all
<?php if (preg_replace('/[^0-9.]/', '', $price) > 0) { ?>
<div class="price"><?php echo $text_price; ?>
Parse error: syntax error, unexpected $end...on line 541
I then changed the code to this:
Code: Select all
<?php if (preg_replace('/[^0-9.]/', '', $price) > 0) ?>
Then I did this:
Code: Select all
<?php if (preg_replace('/[^0-9.]/', '', $price) > 0)
Parse error: syntax error, unexpected '<' ... in line 40
Can someone please give me the correct syntax so I can have products with zero prices remove the prices being displayed?
Thank you.
Aqui amigo
http://www.opencart.com/index.php?route ... de%20price
não sei programar nem nada , apenas coloquei na pasta xml do vqmod
A unica coisa que fiz foi editar o nome do template no arquivo .xml
Obrigado
http://www.opencart.com/index.php?route ... de%20price
não sei programar nem nada , apenas coloquei na pasta xml do vqmod
A unica coisa que fiz foi editar o nome do template no arquivo .xml
Obrigado
I also want prices that I assign as $0 to not show anything at all (I don't even want it to display $0.00). Your solution below almost works:
I really just want prices not to display for certain products which are not for sale. So I was thinking of using your suggestion with an If ... Then statement: IF the product name begins with XYZ..., THEN I could apply the <?php if ($price>0) { ?> code. So I was thinking the code might look something like this:but I'm not sure if that's the proper variable for product name or if such code would even work. Could anyone point me in the right direction?
but it removes the prices from ALL products. Do you think you could refine that code to apply to products that only have a price of $0?dbassa wrote: Try to locate:
in catalog/view/theme/yourtheme/template/product/product.tplCode: Select all
<?php if ($price) { ?>
Replace it for:
Code: Select all
<?php if ($price>0) { ?>
I really just want prices not to display for certain products which are not for sale. So I was thinking of using your suggestion with an If ... Then statement: IF the product name begins with XYZ..., THEN I could apply the <?php if ($price>0) { ?> code. So I was thinking the code might look something like this:
Code: Select all
<?php if($product['name'] == 'XYZ'){?>
<?php if ($price>0) { ?>
<?php } else { ?>
<?php if ($price) { ?>
<?php } ?>
and then the rest of the code
Things like that already exist, to possibly get you an idea on, how they did it.
Ernie
---
Hide Price if Zero 0,00 or Price Empty (OCMOD) OC v.2.x
https://www.opencart.com/index.php?rout ... n_id=24018
---
Hide price if 0 --- FREE OC v.1.5.6.x
https://www.opencart.com/index.php?rout ... n_id=20557
---
Enable / Disable Price for product OC v.2.x
https://www.opencart.com/index.php?rout ... n_id=25639

Ernie
---
Hide Price if Zero 0,00 or Price Empty (OCMOD) OC v.2.x
https://www.opencart.com/index.php?rout ... n_id=24018
---
Hide price if 0 --- FREE OC v.1.5.6.x
https://www.opencart.com/index.php?rout ... n_id=20557
---
Enable / Disable Price for product OC v.2.x
https://www.opencart.com/index.php?rout ... n_id=25639
My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
I actually posted without realizing there was a page 2 to this thread, LOL! Yes, below is the solution that worked for me. Thank-you hoyle.a! By the way, this worked in version 2.3.0.2.
hoyle.a wrote: ↑Thu Jul 12, 2012 3:10 amThats because $price is a STRING usually looking like "$0.00" , which wont work because of the dollar symbol being there. So you use REGEX to grab only numbers and decimal points, then compare that. This is what your if line should look like.
You are going to need to do a find and replace on that if statement to make life easy since you will need to edit most of the files in catalog/view/theme/YOURTEMPLATE/product as well as catalog/view/theme/YOURTEMPLATE/module.
Your welcome...
Code: Select all
if (preg_replace('/[^0-9.]/', '', $price) > 0)
Who is online
Users browsing this forum: No registered users and 13 guests