PHP Web Host - Quality Web Hosting For All PHP Applications $35/month $250/year (Unlimited) - $25/month - 200,000 impressions - Your Ad Could be Here - Click For Details
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Sun May 16, 2004 1:50 am Reply with quote Back to top

Help!

This is driving me insane. Firstly id better explain what im trying to do.

I need to display a product info, picture, default price and special price as it current does, but with one exception; currently when price =$0 then it displays 0.00. I wish to change this so that if price is 0 then NO price is displayed.

I am working from a working example for regular pricing that ive implemented that hides the price if it = 0.

Original Code example
Code:
'text' => '<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><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));


WORKING ALTERATION

Code:
'text' => '<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><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . (($new_products['products_price']> 0) ? $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))) : '');


Note the > 0) ? and the end directly above.

This following - similar line is the one im having trouble with.

Code:
'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $default_specials['products_image'], $default_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials['products_id']) . '">' . $default_specials['products_name'] . '</a><br><s>' . $currencies->display_price($default_specials['products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($default_specials['specials_new_products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</span>');


Dont forget, this line results in the displaying of TWO PRICES rather than one shown in the example and i require BOTH TO BE HIDDEN IF PRICE = 0.

I have tried MANY Variations, an extra brackets in various positions etc .....I just cannot get it right.

PLEASE HELP RAVEN, CHATSERV or any other pro who thinks they can get the punctuation correct.

Regards

Richard
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Sun May 16, 2004 9:14 am Reply with quote Back to top

Why not just do something like
if($currencies->display_price($default_specials['products_price'] != 0)){
echo link code with price
}else{
echo link code without price
}
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Sun May 16, 2004 9:34 am Reply with quote Back to top

Might have to make it just
if($default_specials['products_price'] != 0)){
Get rid of the display_price part there.
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Sun May 16, 2004 9:38 am Reply with quote Back to top

if($currencies->display_price($default_specials['products_price'] != 0)){

I get a parse error on that line
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Sun May 16, 2004 9:45 am Reply with quote Back to top

Its sound I missed a bracket in
if($default_specials['products_price'] != 0)){

But i'd think this
if($default_specials['products_price'] != 0){
or this would work?
if(!$default_specials['products_price'] = 0){

IF those give error try using the compare == values
if(!$default_specials['products_price'] == 0){
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 1:26 am Reply with quote Back to top

I will try thoughs ......thanks

Very Happy
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 1:38 am Reply with quote Back to top

Nope ......Still a parse error on that line.
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 1:42 am Reply with quote Back to top

$info_box_contents[$row][$col] = array('align' => 'center',
'params' => 'class="smallText" width="33%" valign="top"',
if(!$default_specials['products_price'] == 0){

'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $default_specials['products_image'], $default_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials['products_id']) . '">' . $default_specials['products_name'] . '</a><br><s>' . $currencies->display_price($default_specials['products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($default_specials['specials_new_products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</span>');
}else{
'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $default_specials['products_image'], $default_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials['products_id']) . '">' . $default_specials['products_name'] . '</a><br><s>' .'</span>');
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 2:05 am Reply with quote Back to top

Parse error still for that line
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Mon May 17, 2004 7:10 am Reply with quote Back to top

I'm just getting in on this so forgive the question. In your post above you have a line like this
Code:
if(!$default_specials['products_price'] == 0){

'text' => '<a href="' //cut
You can't do that. 'text' => is an array syntax and has to be used in array() form. Or, did you not post all of the code?
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Mon May 17, 2004 7:54 am Reply with quote Back to top

Actually this is what he's been trying to do but I steered him down the wrong path as par for course lately.


<br><span class="productSpecialPrice">' . (($new_products['products_price']> 0) ? $currencies->display_price($default_specials['specials_new_products_price'], tep_get_tax_rate($default_specials['products_tax_class_id']))) . '</span>');
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Mon May 17, 2004 7:59 am Reply with quote Back to top

Maybe it has to be

<br><span class="productSpecialPrice">' . (($default_specials['specials_new_products_price']> 0) ? $currencies->display_price($default_specials['specials_new_products_price'], tep_get_tax_rate($default_specials['products_tax_class_id']))) . '</span>');
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Mon May 17, 2004 9:00 am Reply with quote Back to top

Okay, but if that is the syntax he is using, the IF clause and then the 'text'=> stuff, that will never work. It will always be a syntax error.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 9:08 am Reply with quote Back to top

The IF clause was was not considered........ until suggested by sixonetonoffun........probably because i didnt originally give enough of the code.
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Mon May 17, 2004 9:14 am Reply with quote Back to top

That's fine and I will back out of this one. My point is just the error in the syntax of the construction. His thought process is correct (imagine that Laughing ) - use an IF test to develop the variable string that you will need. Then, call the correct variable construct in your array.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 9:20 am Reply with quote Back to top

Nope ....that didnt work either Sixonetonoffun.
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 9:40 am Reply with quote Back to top

YAY I DID IT Mr. Green

'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $default_specials['products_image'], $default_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials['products_id']) . '">' . $default_specials['products_name'] . '</a><br><s>' . (($new_products['products_price']> 0) ? $currencies->display_price($default_specials['products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])): '') . '</s><br><span class="productSpecialPrice">' .(($new_products['products_price']> 0) ? $currencies->display_price($default_specials['specials_new_products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) : ''). '</span>');
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 9:53 am Reply with quote Back to top

Ok fixed one problem .....Ive got another.

$contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%');

This line results in an error

Warning: Division by zero in /usr/home/******/public_html/modules/catalog_admin/specials.php on line 254

The following lines are used to calculate special price (lines 39 and 40)

$products_price = $new_special_insert['products_price']> 0;
$specials_price = ($products_price - (($specials_price / 100) * $products_price));

Any ideas?
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 10:32 am Reply with quote Back to top

The error is correct, - it is a division of 0 - the point is thats fine by be and i dont want an error everytime i try and assign a new special item to the catelogue. You dont get an error with a calculator.....!

The point of all my mods is to hide the price entirely so the catelogue can be used as a product display - forgetting the prices if the price = 0. (This seems a sensible idea as a standard for all osc if you ask me.)

Regards

Richard.
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 10:34 am Reply with quote Back to top

How can i set it to ignore the error is basically what im asking?

Thanks for your help guys.

Wink
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Mon May 17, 2004 10:41 am Reply with quote Back to top

Something like this
Code:
if ($sInfo->products_price>0) $contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%');
else { // do other stuff }


Last edited by Raven on Mon May 17, 2004 3:08 pm; edited 2 times in total
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
sixonetonoffun
Spouse Contemplates Divorce


Joined: Jan 02, 2003
Posts: 2499

PostPosted: Mon May 17, 2004 11:21 am Reply with quote Back to top

I think the idea was that products have prices. Its not until people started using the osc downloads and wanted to offer both free and paid downloads that people started having trouble with the free products because its kind of an oxy moron thing. Or wanted to give a premium free with the purchase of X dollars or X number of products. Which starts to get comlicated to say the least.
View user's profile Send private message
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Mon May 17, 2004 2:21 pm Reply with quote Back to top

Parse error: parse error, unexpected T_ELSE in /usr/home/*****/public_html/modules/catalog_admin/specials.php on line 256

no joy with that ........
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Mon May 17, 2004 3:07 pm Reply with quote Back to top

Add a semi colon after the closing parentheses.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Rikk03
Worker
Worker


Joined: Feb 16, 2004
Posts: 164

PostPosted: Tue May 18, 2004 1:42 am Reply with quote Back to top

This is what i used in the end Smile

if ($sInfo->products_price>0) $contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%');

else { $contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / 1))) . '%'); }
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum