Author |
Message |
Rikk03
Worker


Joined: Feb 16, 2004
Posts: 164
|
Posted:
Sun May 16, 2004 1:50 am |
|
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 |
|
|
|
 |
sixonetonoffun
Spouse Contemplates Divorce

Joined: Jan 02, 2003
Posts: 2496
|
Posted:
Sun May 16, 2004 9:14 am |
|
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
} |
|
|
|
 |
sixonetonoffun

|
Posted:
Sun May 16, 2004 9:34 am |
|
Might have to make it just
if($default_specials['products_price'] != 0)){
Get rid of the display_price part there. |
|
|
|
 |
Rikk03

|
Posted:
Sun May 16, 2004 9:38 am |
|
if($currencies->display_price($default_specials['products_price'] != 0)){
I get a parse error on that line |
|
|
|
 |
sixonetonoffun

|
Posted:
Sun May 16, 2004 9:45 am |
|
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

|
Posted:
Mon May 17, 2004 1:26 am |
|
I will try thoughs ......thanks
 |
|
|
|
 |
Rikk03

|
Posted:
Mon May 17, 2004 1:38 am |
|
Nope ......Still a parse error on that line. |
|
|
|
 |
Rikk03

|
Posted:
Mon May 17, 2004 1:42 am |
|
$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

|
Posted:
Mon May 17, 2004 2:05 am |
|
Parse error still for that line |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Mon May 17, 2004 7:10 am |
|
I'm just getting in on this so forgive the question. In your post above you have a line like thisCode: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? |
|
|
|
 |
sixonetonoffun

|
Posted:
Mon May 17, 2004 7:54 am |
|
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

|
Posted:
Mon May 17, 2004 7:59 am |
|
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

|
Posted:
Mon May 17, 2004 9:00 am |
|
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

|
Posted:
Mon May 17, 2004 9:08 am |
|
The IF clause was was not considered........ until suggested by sixonetonoffun........probably because i didnt originally give enough of the code. |
|
|
|
 |
Raven

|
Posted:
Mon May 17, 2004 9:14 am |
|
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 ) - use an IF test to develop the variable string that you will need. Then, call the correct variable construct in your array. |
|
|
|
 |
Rikk03

|
Posted:
Mon May 17, 2004 9:20 am |
|
Nope ....that didnt work either Sixonetonoffun. |
|
|
|
 |
Rikk03

|
Posted:
Mon May 17, 2004 9:40 am |
|
YAY I DID IT
'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

|
Posted:
Mon May 17, 2004 9:53 am |
|
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

|
Posted:
Mon May 17, 2004 10:32 am |
|
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

|
Posted:
Mon May 17, 2004 10:34 am |
|
How can i set it to ignore the error is basically what im asking?
Thanks for your help guys.
 |
|
|
|
 |
Raven

|
Posted:
Mon May 17, 2004 10:41 am |
|
Something like thisCode: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

|
Posted:
Mon May 17, 2004 11:21 am |
|
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

|
Posted:
Mon May 17, 2004 2:21 pm |
|
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

|
Posted:
Mon May 17, 2004 3:07 pm |
|
Add a semi colon after the closing parentheses. |
|
|
|
 |
Rikk03

|
Posted:
Tue May 18, 2004 1:42 am |
|
This is what i used in the end
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))) . '%'); } |
|
|
|
 |
|