Zen Cart Logo
Forums / Customization from the Admin / admin radio field

admin radio field

Locked

Views: 1,426

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
27 Jul 2007, 12:02 PM
#1
kodam avatar

kodam

Zen Follower

Join Date:
Jul 2005
Posts:
84
Plugin Contributions:
0

admin radio field

Hello,

I made some radio button on my admin products page (located admin/includes/modules/product/collect_info.php) but they don't remember the choice I made when I preview then submit the product properties.

Can someone tell me how to make them remember what I chose ?
I think I have to store this data in a database slot but I'm kind of lost here.

thank you

My code :

<?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('stock_status', '1', ($stock_ok)) . ' ' . TEXT_PRODUCT_IN_STOCK . ' ' . zen_draw_radio_field('stock_status', '2', ($stock_3_days)) . ' ' . TEXT_PRODUCT_3_DAYS . ' ' . zen_draw_radio_field('stock_status', '3', ($stock_5_days)) . ' ' . TEXT_PRODUCT_5_DAYS . ' ' . zen_draw_radio_field('stock_status', '4', ($stock_out)) . ' ' . TEXT_PRODUCT_OUT_OF_STOCK . ' ' . zen_draw_radio_field('stock_status', '5', ($stock_none)) . ' ' . TEXT_PRODUCT_NOTHING ; ?>
27 Jul 2007, 3:22 PM
#2
brandtim avatar

brandtim

Zen Follower

Join Date:
Apr 2006
Posts:
250
Plugin Contributions:
0

Re: admin radio field

Yep, that's definitely going to require storing the information in the database...

First you'll need to determine which table to store the data in (most probably the one defined by TABLE_PRODUCTS). Then you'll need to add a new attribute to store the data in - say, products_stock_status. Now you have a place to store your data.

Next you need to add a key to the $parameters array in collect_info.php to store the data as well ... then you'll need to modify the statements where the data is stored and retrieved from the database to include products_stock_status.

Last (for the admin, anyway), you'll need to check to see if a value for products_stock_status is set and make it the selected choice in your radio button set. You will probably also want to check to make sure that something got selected for stock_status and return an error if it got left blank...

This is all you need to do for the admin, but if you want to change what gets displayed in the cart to the customer, you'll need to modify includes/modules/YOUR_TEMPLATE/product_listing.php and includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php.

Alternately, if you do not want to have to modify the core code, what would be better would be to create a new product type which would include the stock_status field. See here for instructions:
http://www.zen-cart.com/wiki/index.php/Product_Types

ZenCart is wonderfully customizable but for making changes beyond the templating system you'll really need to know PHP and MySQL ... if you're not well versed in them I suggest reading PHP and MySQL Web Development by Welling and Thompson.

BrandTim

27 Jul 2007, 3:26 PM
#3
kodam avatar

kodam

Zen Follower

Join Date:
Jul 2005
Posts:
84
Plugin Contributions:
0

Re: admin radio field

Ok, thank you.

My part in includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php is already done and working.

I just need to work on a way to store and retrieve data, I'll try what you've told me and post the result here.

Again, thank you

27 Jul 2007, 8:35 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: admin radio field

The product_music type is an example of extra data being stored in additional database tables.

There is also a "book" product type in the downloads section that can be used as another, different, example.