Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
Rikk03
Worker
Worker



Joined: Feb 16, 2004
Posts: 164

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

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: 2496

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

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







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

Might have to make it just
if($default_specials['products_price'] != 0)){
Get rid of the display_price part there.
 
Rikk03







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

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

I get a parse error on that line
 
sixonetonoffun







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

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){
 
Rikk03







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

I will try thoughs ......thanks

Very Happy
 
Rikk03







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

Nope ......Still a parse error on that line.
 
Rikk03







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

$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>');
 
Rikk03







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

Parse error still for that line
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

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

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
sixonetonoffun







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

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>');
 
sixonetonoffun







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

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>');
 
Raven







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

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.
 
Rikk03







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

The IF clause was was not considered........ until suggested by sixonetonoffun........probably because i didnt originally give enough of the code.
 
Raven







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

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.
 
Rikk03







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

Nope ....that didnt work either Sixonetonoffun.
 
Rikk03







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

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>');
 
Rikk03







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

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?
 
Rikk03







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

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.
 
Rikk03







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

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

Thanks for your help guys.

Wink
 
Raven







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

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 
sixonetonoffun







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

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.
 
Rikk03







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

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

no joy with that ........
 
Raven







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

Add a semi colon after the closing parentheses.
 
Rikk03







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

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))) . '%'); }
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©