Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Having trouble with this


stevennickelby

Recommended Posts

Posted

Here is the new release module

I'm trying to have it not display the products price if it equals Zero.

 

It must be simple the only thing I can think of is an if statement,

but everytime I attempt it, it comes up with sql errors,

 

can someone please help! :'( :'( :'(

.............................................

<?php

/*

$Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

?>

<!-- new_products //-->

<?php

$info_box_contents = array();

$info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

 

new contentBoxHeading($info_box_contents);

?>

<?php

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {

$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

} else {

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

}

 

 

 

$row = 0;

$col = 0;

$info_box_contents = array();

while ($new_products = tep_db_fetch_array($new_products_query)) {

$new_products['products_name'] = tep_get_products_name($new_products['products_id']);

$new_products['short_desc'] = tep_get_short_desc($new_products['products_id']);

$info_box_contents[$row][$col] = array('align' => 'right',

'params' => 'class="smallText" height="50" width="20%" valign="top"',

'text' => '<br><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><td valign="top" align="left"><br><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $new_products['short_desc'] . '<br><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));

 

 

$col ++;

if ($col > 0) {

$col = 0;

$row ++;

}

}

 

new contentBox($info_box_contents);

?>

 

<!-- new_products_eof //-->

Posted

try this...

 

near the bottom, where it reads:

$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))); 


$col ++;
if ($col > 0) {
$col = 0;
$row ++;
}
}

new contentBox($info_box_contents);
?>

<!-- new_products_eof //-->

change it to read:

($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'] : ' ';))));


$col ++;
if ($col > 0) {
$col = 0;
$row ++;
}
}

new contentBox($info_box_contents);
?>

<!-- new_products_eof //-->

note I've only included the end of quoted code to help you locate the the area to edit.

Posted

There is also the Hide Price Contribution

 

http://www.oscommerce.com/community/contri...arch,hide+price

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Posted
There is also the Hide Price Contribution

 

http://www.oscommerce.com/community/contri...arch,hide+price

 

 

 

Hi thanks for your replies I appreciate them,

 

Sqeekit I tried the change but it causes a parse errors

Parse error: parse error, unexpected ':' in

\catalog\includes\modules\new_products2.php on line 37

 

 

($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'] : ' ';))));

 

 

$col ++;

if ($col > 0) {

$col = 0;

$row ++;

}

}

 

new contentBox($info_box_contents);

?>

 

<!-- new_products_eof //-->

 

 

AND.....I ALSO TRIED THIS TOO

 

 

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in \catalog\includes\modules\new_products2.php on line 38

 

$currencies->display_price($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'] : ' ';))));

 

 

 

$col ++;

if ($col > 0) {

$col = 0;

$row ++;

}

}

 

new contentBox($info_box_contents);

?>

 

<!-- new_products_eof //-->

 

Thanks alot so far

Posted

ComicWisdom, that looks much better than what I submitted - cool beans - I'm not even sure if my submitted code --- OH it doesn't (* I just noticed response *)

 

oh shoot - now that i look at what i submitted > OPPS - sorry...

 

lot of "(" and ")" mistakes --- sooo...

 

you could try (in same editing location):

(($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))  :  ' ';));

i think that looks right -- lemme look at it a bit -- i'll post pronto if i see something hughly wrong...

 

-------------------------------------------------------------------------

 

ComicWisdom, perhaps you could give me some thoughts on (tiny tip) Allowing "$" in Advanced Search price range (from this forum)

Posted
ComicWisdom, that looks much better than what I submitted - cool beans - I'm not even sure if my submitted code --- OH it doesn't (* I just noticed response *)

 

oh shoot - now that i look at what i submitted > OPPS - sorry...

 

lot of "(" and ")" mistakes --- sooo...

 

you could try (in same editing location):

(($new_products['products_price'] > 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))  :  ' ';));

i think that looks right -- lemme look at it a bit -- i'll post pronto if i see something hughly wrong...

 

-------------------------------------------------------------------------

 

ComicWisdom, perhaps you could give me some thoughts on (tiny tip) Allowing "$" in Advanced Search price range (from this forum)

 

 

It works the Trick!, cheers for your patience and help :thumbsup:

Posted

cool :D -

 

be sure to check out that tip Allowing "$" in Advanced Search price range - anyone one that sells anything and still has (at least something left) of the default Advanced Search should check out this tip - else customers may not be finding what they're looking for --- because of merely including a "$" symbol in the price range fields...

 

[ note such is for USD - but with rtrim() it can be adapted for euros too - lol ;) ]

Posted

a "pretty" afterthought...

 

taking another peek, i just realized that applying the last version of the edit (that works ;) ) might cause a blank line an the bottom of the infobox [ in some browsers ] if the price is "none" --- to avoid such you can move ( CUT & paste ) the double BR area ( '<br><br>' . ) immediately preceeding the conditional statement...

 

from:

'<br><br>' .  (($new_products['products_price'] > 0) ?

to:

(($new_products['products_price'] > 0) ? '<br><br>' .

now the bottom of the box will be the same from the last line in all browsers wether there be a price or not....

Archived

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

×
×
  • Create New...