Post by dbassa » Fri May 04, 2012 5:37 am

Did you put:echo $price;?

We need to know what $price has.

Please do it and tell me.

Thanks!

User avatar
Active Member

Posts

Joined
Tue May 19, 2009 12:11 am
Location - Spain

Post by malinga91 » Mon May 14, 2012 12:07 pm

Hi Davian,
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>   
If you can just edit this code and send me... It's a great help for me.

Thank you.
Take care.

New member

Posts

Joined
Wed Apr 04, 2012 1:00 pm

Post by dbassa » Mon May 14, 2012 2:28 pm

Please maligna, as I told you before, try to add this line of code:

Code: Select all

echo $price; 
(after this:)

Code: Select all

<div class="pPrice">
And tell us what is the value for price when you enter to the page.

Thanks,

User avatar
Active Member

Posts

Joined
Tue May 19, 2009 12:11 am
Location - Spain

Post by malinga91 » Mon May 14, 2012 8:43 pm

:( I tried once. It's not working. I'll try again..

Thanks....

New member

Posts

Joined
Wed Apr 04, 2012 1:00 pm

Post by dbassa » Tue May 15, 2012 3:44 am

:) ok

User avatar
Active Member

Posts

Joined
Tue May 19, 2009 12:11 am
Location - Spain

Post by hoyle.a » Thu Jul 12, 2012 3:10 am

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)

User avatar
Newbie

Posts

Joined
Mon Jul 18, 2011 4:15 am
Location - Seattle, WA

Post by mggal » Wed Jan 15, 2014 12:57 am

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)
This is the solution! (Two years laters still running. Don't forget change de code in others .tpl archive (category, search and others!!)

Thank you a lot!! :)

Newbie

Posts

Joined
Wed Jan 15, 2014 12:45 am

Post by toad78 » Tue Jan 28, 2014 2:26 am

I've tried the above code by doing this in product.tpl:

Code: Select all

<?php if (preg_replace('/[^0-9.]/', '', $price) > 0) { ?>
<div class="price"><?php echo $text_price; ?>
and received the following error message:
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) ?>
And the prices still displayed (those that are set to zero price)

Then I did this:

Code: Select all

<?php if (preg_replace('/[^0-9.]/', '', $price) > 0)
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.

New member

Posts

Joined
Sun Dec 08, 2013 8:30 am

Post by marciosilk » Fri Mar 28, 2014 12:55 am

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

Newbie

Posts

Joined
Fri Mar 28, 2014 12:53 am

Post by RideTheWave » Sun Jun 04, 2017 10:24 am

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:
dbassa wrote: 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) { ?>
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?

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
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?

New member

Posts

Joined
Fri May 19, 2017 8:29 am

Post by IP_CAM » Sun Jun 04, 2017 10:40 am

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

Contact: jti@jacob.ch
---
Demos:
OpenCart LIGHT 1.5.6.5: http://www.openshop.li/light/
OpenCart V-PRO 1.5.6.5: http://www.velomech.ch/shop/
V-PRO Multi Theme View: http://www.openshop.li/shop/
---
Downloads:
Free Github OC Downloads: https://github.com/IP-CAM
1'900+ FREE OC Extensions from the world's largest Github OC Archive.
---
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by RideTheWave » Sun Jun 04, 2017 11:11 am

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 am
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)

New member

Posts

Joined
Fri May 19, 2017 8:29 am

Newbie

Posts

Joined
Thu Feb 16, 2017 7:45 pm
Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 58 guests