Jump to content
Sign in to follow this  
Fireflight

Add extra fields to products using radio buttons not text fields

Recommended Posts

Hi there all.

 

I'm using Product Extra fields to add ISBN, Author, etc, to the products for a store I'm setting up. I've run into a situation where there are a limited number of options for one field (Ex. Binding: Hardcover, Softcover, Spiral). Is there an add-on that would allow me to create extra fields, but use radio buttons or a select field to choose the option? I have visions of the store admin going mad as they add new products and have to type the attributes each time.

 

This is purely for the admin side, customers would only see the text value.

Share this post


Link to post
Share on other sites

Hi there all.

 

I'm using Product Extra fields to add ISBN, Author, etc, to the products for a store I'm setting up. I've run into a situation where there are a limited number of options for one field (Ex. Binding: Hardcover, Softcover, Spiral). Is there an add-on that would allow me to create extra fields, but use radio buttons or a select field to choose the option? I have visions of the store admin going mad as they add new products and have to type the attributes each time.

 

This is purely for the admin side, customers would only see the text value.

 

 

Hii FF:

 

I got your post today when I was searching internet for the same issue which you have raised out here, but unfortunately I didn't get anything on web. So, I decided to work on this issue at my own and I got success on it. Here I am posting the whole code for your ready reference and use. You can use this code as it is if you wish to or you can change the field names or values as per your requirements:

 

Here we go......

 

First thing first, you have to create a field under your PRODUCTS table in your shopping cart's database.

 

add the following field: " products_binding "

 

Then create three RADIO BUTTON FIELDS in your ADMIN's CATEGORIES.PHP file. You can use following code:

 

file path: admin/categories.php

 

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_BINDINGS; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_radio_field('products_binding', '1', $hc_status) . ' ' . TEXT_PRODUCT_HARDCOVER . ' ' . tep_draw_radio_field('products_binding', '2', $sc_status) . ' ' . TEXT_PRODUCT_SOFTCOVER . ' ' . tep_draw_radio_field('products_binding', '3', $spr_status) . ' ' . TEXT_PRODUCT_SPIRAL; ?>

</td>

</tr>

 

You may be surprised with the FIELD LABELS i.e. TEXT_PRODUCTS_BINDINGS under first <TD>, and TEXT_PRODUCT_HARDCOVER, TEXT_PRODUCT_SOFTCOVER, TEXT_PRODUCTS_SPIRAL etc. well, put the following code under your ADMIN's CATEGORIES.PHP file at following path:

 

file path: admin/includes/languages/english/categories.php ... Add these four lines at the end of the file before closing php ( ?> ) tag :

 

define('TEXT_PRODUCTS_BINDINGS', 'Binding: ');

define('TEXT_PRODUCT_HARDCOVER', 'Hardcover');

define('TEXT_PRODUCT_SOFTCOVER', 'Softcover');

define('TEXT_PRODUCT_SPIRAL', 'Spiral');

 

 

After this, you need to get back the values of these three Radio Buttons from database when you edit the particular product. For this we are going to use a switch case to get the exact selected value. Use following code as it is if you have to use exact same fields/values. Put this code at LINE NO.: 488 OR near around the predefined switch case code used for products_status field in ADMIN's CATEGORIES.PHP file:

 

file path: admin/categories.php

 

// CODE TO GET THE PRODUCTS_BINDING FROM THE DATABASE

 

if(isset($pInfo->products_binding))

{

switch($pInfo->products_binding)

{

case '3':

$hc_status = false;

$sc_status = false;

$spr_status = true;

break;

 

case '2':

$hc_status = false;

$sc_status = true;

$spr_status = false;

break;

 

case '1';

$hc_status = true;

$sc_status = false;

$spr_status = false;

break;

}

}

 

// CODE TO GET THE PRODUCTS_BINDING FROM THE DATABASE

 

That's all we have to do. But remember one thing, I have not defined the whole process of creating these three Radio Button Fields. You need to put the variable i.e. PRODUCTS_BINDING (use in small case) at so many places under your ADMIN's CATEGORIES.PHP file to get the desired output. To achieve this, you can follow any of the field name e.g. " products_status " by just copying it and then search for that particular field name from head to toe of the file and paste your new field name under each DATABASE QUERY along with it and you surely will get what you want.

 

Hopefully, I am able to help you. If you face any trouble during implementation of all this, then feel free to ask.

 

Cheers

Sham


design Lover

Share this post


Link to post
Share on other sites

Hi there all.

 

I'm using Product Extra fields to add ISBN, Author, etc, to the products for a store I'm setting up. I've run into a situation where there are a limited number of options for one field (Ex. Binding: Hardcover, Softcover, Spiral). Is there an add-on that would allow me to create extra fields, but use radio buttons or a select field to choose the option? I have visions of the store admin going mad as they add new products and have to type the attributes each time.

 

This is purely for the admin side, customers would only see the text value.

 

The Extra Product Fields contribution version 2 and higher allows you to easily create fields that use radio buttons, drop down lists or check boxes. It even includes a utility to convert data from Product Extra Fields to Extra Product Fields.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×