Shopping Cart Reviews SHOPPING CART REVIEW
   
  HOME REVIEWS NEWS FORUM ABOUT US RESOURCES SUBMIT ARTICLES SUBMIT A CART
 
AgoraCart 5.0.0 Release Candidate 1 by end of January 2006
Release Candidate 1 (RC1) for version 5.0.0 of AgoraCart is very close to being a reality. Despite set backs and under estimating the time needed to develop and recode certain features, RC1 is tentatively targeted for release by end of January 2006.

AgoraCart 5.0.0 RC1 is not a beta version, and is fully capable of running in a production environment. However, it is missing some features, mostly gateways. Layout refinements will also need to be made prior to the final release.

Some features, such as the static page builder, froogle exporter, and the "buy now" button generator will be released at a later date.

ME
Understanding osCommerce - Adding a Field Part 2
Last time we talked about our plan to add a new field to the products display. We discussed what we are going to do, now its time to talk about how to do it. There is a lot of information to cover, and technical information at that so lets jump right in.

A common tool for managing databases which is available with many web hosts is known as phpMyAdmin. It's the tool I always use, so these instructions will based around using phpMyAdmin and will serve as a mini tutorial on the tool itself. If you don't have phpMyAdmin available and you haven't worked on you database directly before, you'll want to check the documentation that comes with your hosting control panels or contact you hosting company for advice.

phpMyAdmin provides a graphical user interface for working with databases that makes most tasks fairly easy to perform. Its accessible through an icon or link on your hosting control panels. My web hosting uses cpanel and I also have an unlimited number of databases available to me. Therefore when I click on the database icon within my control panels, I'm presented with a screen which allows me to manage the user accounts for my existing databases as well as create new ones. Scrolling down to the bottom of the screen, I find a link to phpMyAdmin, which I click on to take me to that tool. If yours is layout differently and you have trouble finding phpMyAdmin, consult your web host for directions.

Ok, so now hopefully we are all inside the phpMyAdmin tool. Again because I have multiple databases available to me, I'm provided with a dropdown list to select the database I wish to manage. If that is the case for you, find your osCommerce database in the dropdown list and select it. If you only have one database available, you will likely already have the database selected.

phpMyAdmin uses a frames layout, so with the database selected, in the left hand frame you have a list of the tables that make up your osCommerce database. We want to scroll down that list and look for the "products" table. The listed name is a link, so clicking on it changes the display in the main frame on the screen.

Once we have clicked on the "products" table name in the left hand frame, we are presented with a structure view of the products table inside the main frame area, which looks something like this:

Table View

Here we see a list of the existing columns within the products table with their respective attributes. At the bottom of this list and underneath a horizontal bar is a small input form which is used to add a new field:

Add Column

The default is to add one (1) new field, however we can change that value to add as many new columns as we like. In this case one is all we need so we'll leave it at the default. Next we have a series of radio buttons which allow the ability to change the order of the entry point for the new field. In most cases added it to the end of the table works just fine, so we'll also leave things in the default. Everything is all set so we can go ahead and click on the "Go" button.

We now arrive at a new screen which is a form for our new column definition. I've cropped the image to make it display better on this page, yet kept the important input boxes for our task:

Define Field

The inputs we will be working with here are Field, Type, Length/Values, and Null. I'll give a brief explanation as to the type of information that needs to be entered as well as what should be entered for our specific example.

Field is the name of our new column and how the column will be identified with any SQL calls we make in our code. We'll enter "products_sample" here. The osCommerce convention is to use column names which are prefixed by the table name followed by an underscore and a descriptive name. In most cases its best to keep that descriptive name short yet long enough to be self documenting. The reason for keeping it short is that we are going to have to type that name in our code, obviously keeping it short means less typing and less chance for errors.

Type refers to the data type of the column. There are many different types available although they primarily fall into four categories, text, numeric, date, and Boolean (true/false). The default here is varchar which happens to be the most common column data type. Varchar is a type of text or character type which provides some efficiency in the way the data is stored. Varchar has the ability to adjust downward to the size of the data which is stored within the particular column. This helps to decrease the amount of disk space required to hold the data base. Since our new column will hold character data, we'll leave the default at varchar.

Length/Values defines the size of the new column and with varchar refers to the number of characters the field will hold. It's good practice to define the size of the column at a reasonable size, in other words not to go overboard yet large enough to hold the foreseeable data which it will hold. If need be we can always go back and make the column larger, however generally speaking you don't want to be doing that on a regular basis. In our example we need enough space to display the file name with it's extension. We'll store all the sample files in a central location so the path will be common to all sample files and therefore we won't need to store the path. I'm thinking 50 characters should do the trick, so we'll enter 50 for the Length/Values input box.

Null tells the database whether or not it will accept a new row in the table with the column not having any value entered. There are some fields which should always contain a value, for example name. However if there is a chance the column will be empty and the application will still function normally we can define the column to allow nulls. Since there may be situations where we don't have a sample file for one or more of our products, we are going to change the default value here from "not null" to "null".

Let's review what we have entered in our new field definition. In the Field input box we entered "products_sample", for type we left things at the default of "varchar", in the Length/Values input box we entered 50 for the maximum allowable characters, and we selected "null" as the value for the null dropdown list. Ensure all these values are entered correctly and click the "Save" button at the bottom of the page.

Assuming all has gone as expected, we should now be taken back to the structure view of the products table. We should see that our new column now appears at the bottom of the list of column names. We're all set, this step is complete.

In part 3 we will get into the PHP code, we'll work on the product detail screen adding a new field to the form. We'll also write some code to capture the data entered into that new field and save it to the database.

Happy Coding!

HOME | REVIEWS | NEWS | FORUM | ABOUT US | RESOURCES | SUBMIT ARTICLES

 

Creative Commons License This work is licensed under a Creative Commons Attribution-No Derivative Works 2.5 License. Unless otherwise labeled by its originating author, the content found on Shopping Cart Review is made available under the terms of a Creative Commons Attribution-No Derivative Works 2.5 License, with the exception that no rights are granted -- since they are not ours to grant -- in any logo, graphic design, trademarks or trade names.