You are here:  » Display a different image if price is zero

Support Forum



Display a different image if price is zero

Submitted by kiddaclo on Tue, 2010-02-16 20:11 in

Hi,

I'm trying to set it up so in product.php I have a image link to the merchant that changes if the price is on zero. I can get it working with just images but when I insert the dynamic link it all goes pear shaped!
I'm a total php newbie so this is probably way off

<?php
if ( $mainProduct["price"] > 0 ) {
echo "<a target='_BLANK' href='<?php print tapestry_buyURL($priceProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$priceProduct["merchant"]); ?>><img src='logos/1.gif' width='100' height='30' alt='blah' border='0' /></a>";
} else {
echo "<a target='_BLANK' href='<?php print tapestry_buyURL($priceProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$priceProduct["merchant"]); ?>><img src='logos/2.gif' width='100' height='30' alt='blah blah' border='0' /></a>";
}
?>

Submitted by support on Wed, 2010-02-17 10:28

Hi,

The code actually looks fine - but if you're working with re-written URLs (e.g. /product/product-name.html) the img src would need to be...

src='/logos/1.gif'

(assuming that /logos/ is in the top level folder)

Otherwise, it would depend on the location in product.php - if you're not sure if you could email me your modified file I'll check it out for you...

Cheers,
David.

Submitted by kiddaclo on Wed, 2010-02-17 13:40

Hi David,

I can get the images working fine it's just when I add the links to the code I get:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/conversi/public_html/blah/html/product.php on line 51

Line 51 being:
echo "<a target='_BLANK' href='<?php print tapestry_buyURL($priceProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$priceProduct["merchant"]); ?>><img src='logos/1.gif' width='100' height='30' alt='blah' border='0' /></a>";

Cheers,
Chris.

Submitted by support on Wed, 2010-02-17 13:54

Hi Chris,

As it's in PHP mode already at that point there's no need for the additional tags - have a go with just:

echo "<a target='_BLANK' href='".tapestry_buyURL($priceProduct)".' ". javascript_statusBar(translate("go to")." ".$priceProduct["merchant"])."><img src='logos/1.gif' width='100' height='30' alt='blah' border='0' /></a>";

Cheers,
David.

Submitted by kiddaclo on Wed, 2010-02-17 14:03

Hi David,

Now I get:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/conversi/public_html/trademymobile.co.uk/mobile-phone-recycling/html/product.php on line 51

Cheers,
Chris.

Submitted by support on Wed, 2010-02-17 14:07

Hi Chris,

Could you email me your html/product.php and I'll check it out in full for you...

Cheers,
David.