Post by markisonfire » Sun Jan 29, 2012 4:18 am

This should be a pretty simple help request, I just can't seem to get it working. Basically, I want to lay an image over another image when $price is greater than a certain value. Here is my code:

Code: Select all

<?php if($price >= 150) { ?><div style="position: relative;"> <?php } ?>
and then, later...

Code: Select all

<?php if($price >= 150) {
 ?><img style="position: absolute; top: 0; right: 0; width: 340px; height: 340px;" src="/image/freeshippingoverlay.png" /></div><?php
 } ?>
Now, I'm pretty sure the PHP syntax is correct, so what's the deal with $price? What's the correct way to handle this? I want it so that if the price of the product is greater than $150, it will show this code.

All help is greatly appreciated!

Thanks 8)

New member

Posts

Joined
Sat Oct 29, 2011 8:33 am

Post by victorj » Sun Jan 29, 2012 4:36 am

You also need to adapt it to the apropriate tpl files to show it.

Very interesting are you sharing ?

Koeltechnische deurrubbers eenvoudig online op maat bestellen.
Alle niet stekplichtige onderdelen zoals scharnieren, sloten, randverwarming en verlichting voor alle typen koelingen en vriezers.
https://koelcel-onderdelen.com


User avatar
Expert Member

Posts

Joined
Sat Jun 25, 2011 4:09 am
Location - Alkmaar Holland

Post by markisonfire » Sun Jan 29, 2012 4:50 am

victorj wrote:You also need to adapt it to the apropriate tpl files to show it.

Very interesting are you sharing ?
Well, actually, that's in the tpl file. I will definitely share once I get it working. I suppose I should place part of this in the controller file and then call it as a variable. I'll try that and see what happens.

New member

Posts

Joined
Sat Oct 29, 2011 8:33 am

Post by victorj » Sun Jan 29, 2012 5:21 am

i know that for the product page there are 3 files working togeter

catalog/controler/product/product.php
catalog/model/catalog/product.php
catalog/view/yourtheme/template/product/product.tpl

when adding functionality all 3 files are involved

thwe php goes into the php files and they command the template file

Koeltechnische deurrubbers eenvoudig online op maat bestellen.
Alle niet stekplichtige onderdelen zoals scharnieren, sloten, randverwarming en verlichting voor alle typen koelingen en vriezers.
https://koelcel-onderdelen.com


User avatar
Expert Member

Posts

Joined
Sat Jun 25, 2011 4:09 am
Location - Alkmaar Holland

Post by Qphoria » Sun Jan 29, 2012 6:04 am

markisonfire wrote:This should be a pretty simple help request, I just can't seem to get it working. Basically, I want to lay an image over another image when $price is greater than a certain value. Here is my code:

Code: Select all

<?php if($price >= 150) { ?><div style="position: relative;"> <?php } ?>
"$price" is a formated string value, not a number

Try ($product_info['price'] > 150) as that is the unformatted price

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by markisonfire » Sun Jan 29, 2012 6:18 am

Qphoria wrote:
markisonfire wrote:This should be a pretty simple help request, I just can't seem to get it working. Basically, I want to lay an image over another image when $price is greater than a certain value. Here is my code:

Code: Select all

<?php if($price >= 150) { ?><div style="position: relative;"> <?php } ?>
"$price" is a formated string value, not a number

Try ($product_info['price'] > 150) as that is the unformatted price
That's the stuff, right there. A question about MVC for you, then, Mr. Q. Should this be in the controller file? What would the best practice be for something like this? Should I place this in the controller and then call it with a variable in the view tpl file?

[edit] And while we're at it, what would I call if I wanted to have this happen in, say, featured_content.tpl? $product_info['price'] returns a nasty little error. [/edit]

The code you posted works, by the way. I assumed that $price wasn't a numerical value, I just wasn't too sure what to do. Thanks!

New member

Posts

Joined
Sat Oct 29, 2011 8:33 am
Who is online

Users browsing this forum: Amazon [Bot] and 58 guests