Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

IF TRUE : IF FALSE continued


Guest

Recommended Posts

I thought I had the whole IF TRUE : IF FALSE thing figured out but it seems that I'm still not able to conquer the expression when there is more than one display variable! :o

 

My (latest) dilemma is this... in product_info.php I want to limit the ability to "click to enlarge" the images of products whose price > $0

 

This is because all my products with a price > $0 are coffee blends, and I have only given them product images for decoration so there's no need to enlarge them.

 

I only need the products that I'm not selling online (ie. the products where price = $0) to be enalrged because there's actually a benefit to this as they tend to be pics of coffee machines or kitchen equipment where details matters.

I have been playing around with code between line 104-115 in product_info.php

 

<?php
   if (tep_not_null($product_info['products_image'])) {
?>
         <table border="0" cellspacing="0" cellpadding="2" align="right">
           <tr>
             <td align="center" class="smallText">
<script language="javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>

 

Nothing I've done works as it should. Any change I make seems to affect both products with price = $0 and > $0... and I can't get both the hyperlink used on the image and the hyperlinked "Click to enlarge" to go away when price > $0

 

It's a doozy but I promise to contribute lots of solutions to this forum once I become a "PHP Guru" too! :)

Link to comment
Share on other sites

I don't think that the ?: operator will give you what you want here. I would probably try to change the code to look like:

<?php
  if (tep_not_null($product_info['products_image'])) {
?>
        <table border="0" cellspacing="0" cellpadding="2" align="right">
          <tr>
            <td align="center" class="smallText">
<?php
   if ($product_info['products_price'] > 0) {
     echo tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"');
   } else {
?>
<script language="javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>
<?php
   }
?>

Hth,

Matt

Link to comment
Share on other sites

Matt... you again!? ;)

 

Your solution worked... thank you so much - you've saved me a lot of time. I would have been trying to work it out until the wee hours of the morning.

 

I'll have to credit you on my site once it's finished! :)

 

Sincerely, thanks again,

J

Link to comment
Share on other sites

  • 4 years later...
Matt... you again!? ;)

 

Your solution worked... thank you so much - you've saved me a lot of time. I would have been trying to work it out until the wee hours of the morning.

 

I'll have to credit you on my site once it's finished! :)

 

Sincerely, thanks again,

J

 

Hi, I have set the display default image to FALSE in the admin, so there is no broken image link when there is no image for the product.

 

But when there is no image, the CLICK TO ENLARGE button still there. How could I get rid of this click to enlarge when there is no image for the product?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...