Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP Error while trying to add an extra field in categories.php


jonw118

Recommended Posts

Posted

Hello,

 

I am trying to add a new field right after the "Product Name" and before the "Product Price".

 

The field I am creating is called "Displayed Price". I need this to display another price on the site for a product (doesn't actually have to figure into anything - just want the price shown).

 

I essentially went in the categories.php and everywhere there was a products_name line of code, I copy and pasted immediately after the same code, but inserted displayed_price instead of products_name.

 

For the MySQL I ran: ALTER TABLE `products_description` ADD COLUMN `displayed_price` VARCHAR(64) AFTER `products_name`;

 

So everything should work, right?

 

But I now get the error: Fatal error: Call to undefined function tep_get_displayed_price() in /home/***/public_html/projects/****/store/admin/categories.php on line 646

 

Does anyone have any thoughts? I can post the code... but it's so long wanted to see anyone's thoughts first if it's something simple I'm missing.

 

Here's the code from line 646:

 

<td class="main">Price Displayed On Site:</td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('displayed_price[' . $languages[$i]['id'] . ']', (isset($displayed_price[$languages[$i]['id']]) ? stripslashes($displayed_price[$languages[$i]['id']]) : tep_get_displayed_price($pInfo->products_id, $languages[$i]['id']))); ?></td>
	  </tr>

Posted

Hi Jon,

 

Did you define this function in both the public side of the website AND the admin side, function needs to be in both .../includes/functions/general.php files?

 

Frank

Posted
Hi Jon,

 

Did you define this function in both the public side of the website AND the admin side, function needs to be in both .../includes/functions/general.php files?

 

Frank

 

Thanks for trying to help! I really appreciate it.

 

Yes, here's what I had in there...

 

////
// Return a products display price
// TABLES: products
 function tep_get_displayed_price($product_id, $language = '') {
global $languages_id;

if (empty($language)) $language = $languages_id;

$product_query = tep_db_query("select displayed_price from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language . "'");
$product = tep_db_fetch_array($product_query);

return $product['displayed_price'];
 }

////

Posted

Actually... I didn't add that into the functions in the admin. Ooops.

 

So it appears now. But, I've run into another issue.

 

Right now in the database where I inserted that new column all the results are "Null".

 

But I tried adding in a result for one product, and the "Null" in the db disappears, but it doesn't record anything.

Posted
Actually... I didn't add that into the functions in the admin. Ooops.

 

So it appears now. But, I've run into another issue.

 

Right now in the database where I inserted that new column all the results are "Null".

 

But I tried adding in a result for one product, and the "Null" in the db disappears, but it doesn't record anything.

 

Wow. This is frustrating. I can't get it to write to the db to save my life. Are any other files supposed to be updated besides the categories.php, and general.php?

 

Thanks!

Posted

Hi jon

 

If i am not mistaken, your new diplay price should have similar characteristics to the product price both through the pages and the mysql.

You might need to find instances where products price is used and follow that path instead of the products name.

 

Hope this helps

 

louie

Posted
Actually... I didn't add that into the functions in the admin. Ooops.

 

So it appears now. But, I've run into another issue.

 

Right now in the database where I inserted that new column all the results are "Null".

 

But I tried adding in a result for one product, and the "Null" in the db disappears, but it doesn't record anything.

 

If you say the NULL disappears then something was written to the field, it's probably a blank character. Try looking in the admin/categories.php for a line similar to this, it's around line 240(my categories.php has had several changes so line #'s probably won't make)

 

$sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),

 

make sure after this line that you have assigned the new information to the $sql_data_array....just put it anywhere in the following list

use something like this format 'display_price' => tep_db_prepare_input($HTTP>POST_VARS['display_price']),

 

just make sure the the names in the quotes match what name you have in the database for that column.

 

Give that a shot .... as always BACKUP FIRST

 

Frank

Archived

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

×
×
  • Create New...