That Software Guy! eCommerce Starts Here!

Adding a New Field to the Zen Cart product Table

Donate: This is free software. Show your appreciation by supporting my efforts. Donate

Relevance: Zen Cart™ 1.5.x.

These are the steps required to add a new field to the products table.

Adding Radio Buttons

For this example, we'll add the field "is_kit" to the products table, which is needed by the mod Kitbuilder. This field is a radio button, which is either Yes or No.
  1. Add the new field to the database. Go to Admin->Tools->Install SQL Patches, and in the box, enter
    ALTER TABLE products ADD is_kit tinyint(1) default '0' NOT NULL;
  2. Modify the file admin/includes/languages/english/product.php and add the following line:
    define('TEXT_IS_KIT', 'Is Product Kit?');
  3. Modify the file admin/includes/modules/update_product.php and below the line
                                'products_model' => zen_db_prepare_input($_POST['products_model']),^M
                                'is_kit' => zen_db_prepare_input((int)$_POST['is_kit']),
  4. Modify the file admin/includes/modules/product/collect_info.php and change the select statement that uses
    p.product_is_free, p.product_is_call,
    p.is_kit, p.product_is_free, p.product_is_call,
    Then above the comment
    // Product is Free
    // is_kit
        if (!isset($pInfo->is_kit)) $pInfo->is_kit = '0';
        switch ($pInfo->is_kit) {
          case '0': $in_is_kit = false; $out_is_kit = true; break;
          case '1': $in_is_kit = true; $out_is_kit = false; break;
          default: $in_is_kit = false; $out_is_kit = true;
    Then above
                <td class="main"><?php echo TEXT_PRODUCT_IS_FREE; ?></td>
                <td class="main"><?php echo TEXT_IS_KIT; ?></td>
                <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('is_kit', '1', ($in_is_kit==1)) . ' ' . TEXT_YES . '  ' . zen_draw_radio_field('is_kit', '0', ($in_is_kit==0)) . ' ' . TEXT_NO; ?>