X-Cart Mods, X-Cart Addons - WebsiteCM
 
X-Cart Excellence eZine
Subscribe for proven tips and special discounts!
   Forum Search
Forum Menu
Quick Links
Forum Login
Username:

Password

Remember Me
Forum Expert(s)
X-Cart Mods, X-Cart Addons - WebsiteCM
Developing websites since the early-to-mid 90's, and working extensively with e-commerce since 2001, Jon Peters of WebsiteCM is equipped to assist you with your design, programming, e-commerce, and x-cart specific questions.

Adding Product Management fields

About this Thread:
You are viewing the thread Adding Product Management fields in the eCommerce forum.

  #1  
Old January 9th, 2008, 06:47 AM
tap tap is offline
Junior Member
 
Join Date: Jan 2008
Posts: 14
Default Adding Product Management fields

I've installed X-Cart Gold v4.1.9 on a local server for testing/development and I want to add a new field to the Product Details page under Product Management. I've updated the associated .tpl file to add the text entry field that I want and this displays fine.

I've also created a new table in the database that contains the values I want to use along with the associated productid values.

I tried adding the following to func.product.php:

**************
if (empty($tmp))
$tmp = func_query_first("SELECT param00 FROM $sql_tbl[products_added] WHERE id = '$product[productid]'");
if (!empty($tmp)) {
$product = func_array_merge($product, $tmp);
$product['param00'] = true;
}
**************
thinking that this would add my new value from my new table to the $product array, but this didn't work. All that is returned in my field is "1", but I don't understand why this is.

Any help with this would be greatly appreciated as I need to customize the cart a good bit for our needs.

Thanks, Troy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old January 9th, 2008, 07:36 AM
admin admin is offline
Jon Peters (Admin)
 
Join Date: Aug 2007
Location: Vancouver, Canada
Posts: 99
Default

You shouldn't need to edit func.product.php.

To add a new field to your product add/modify page (without using x-cart's built in "Extra Fields", you neeed to:

1) Add the new database field to the products table.
2) Modify skin1/main/product_details.tpl in order to put the field on the template for editing.
3) Modify include/product_modify.php in the section:

Code:
$query_data = array(
Step 3 is likely what you are missing, which is necessary to save the field to the database. It should then show up in your product array by default.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old January 9th, 2008, 07:54 AM
tap tap is offline
Junior Member
 
Join Date: Jan 2008
Posts: 14
Default

Thank you for your quick reply! Maybe I've misunderstood. I had wanted to store this data in a separate table because I was concerned that when I applied future patches to X-Cart I would lose these modifications.

Am I correct in understanding that if I add these values to the admin backend using the method you've described that this will not be "lost" in the future when patches/upgrades are applied?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old January 9th, 2008, 10:50 AM
admin admin is offline
Jon Peters (Admin)
 
Join Date: Aug 2007
Location: Vancouver, Canada
Posts: 99
Default

You can use the format I've provided and the information will not be lost when patches and upgrades are applied. Even moving from branch to branch the database upgrade will leave the "new" fields in tact.

If you want to continue with the path you have chosen then you will want to:

1) Update include/product_modify.php to update your new database table.

2) Modify your code in func.product.php. Currently the reason it is always returning 1 appears to be because you set the $product['param00'] value from the query but then you overwrite it by specifying $product['param00'] = true; (true is equivalent to 1).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old January 9th, 2008, 10:52 AM
admin admin is offline
Jon Peters (Admin)
 
Join Date: Aug 2007
Location: Vancouver, Canada
Posts: 99
Default

Also this code should be more efficient:

Code:
if (empty($tmp))
$product['param00'] = func_query_first_cell("SELECT param00 FROM $sql_tbl[products_added] WHERE id = '$product[productid]'");
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old January 9th, 2008, 12:26 PM
tap tap is offline
Junior Member
 
Join Date: Jan 2008
Posts: 14
Default

Hi Jon,

Thanks for your responses and guidance. They've been very helpful. I'm happy to continue working as you suggested. I just wanted to make sure that modifications wouldn't be lost with future upgrades. I can't say enough about how helpful your timely responses have been! I'm excited to see this forum grow as a resource for users like me.

Thanks, Troy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Site Map