Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add extra fields to products using radio buttons not text fields


Fireflight

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.

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

  • 2 months later...

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...