views:

26

answers:

1

Assume a simple order processing system. A Category is selected, which lists range of products, and when a product is selected, it allows for details about that product to be entered. The details differ for each product.

The admin user wants enable adding new products to this system, without the programmer getting involved. The challenging part is the details form is different for each product.

Consider the following work flow:

Add Service -> Add Genera Properties (Description, Price, BillType, AveActivationTime) -> Add Specific Properties (FieldName, ValueType, MandatorOrNot).

Currently, the system has a pop up for each product. But that has be desiged by a programmer. It seems the form generation has to be automatized. What is a good approach to dealing with this issue?

+1  A: 

Perhaps have a customfields table, with the following fields:

id (auto increment?)
itemType (link to type of item that uses these fields)
name
type
options
default
required

Then, when you display the update form you can loop through all the custom fields attached to the current itemType. If the field is a string, display a string input; if it's an option, display a select box etc.

Then store the actual values in a customdata table:

id
itemID
fieldID
value

You may want to extend this to allow, for example, sharing custom fields across different itemTypes.

Have you looked at existing e-commerce solutions? I would think most of them have this functionality built in. No point in reinventing the wheel.

adam
Thank you for your suggestions. Looping through custom fields for the product seems good idea. There exists a rudimentary order processing system that can invoice, and track recurring billing. Do you ave any good open source order processing / e commerce solution suggestions?
Natkeeran