Page 13 of 16 FirstFirst ... 31112131415 ... LastLast
Results 121 to 130 of 159
  1. #121
    Join Date
    Oct 2007
    Posts
    19
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    I got it. There's another file, copy_to_confirm.php that also needs to be updated for this to work fully. I'm on an older version of Zen Cart so maybe that's why nobody else seems to have this issue..

  2. #122
    Join Date
    May 2012
    Posts
    2
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    I know this original thread is a few years old, so I'm hoping someone might still be watching it and be able to help.

    I'm currently working on my wifes shop (http://www.katiesgiftshop.co.uk) And I've added a new field for Google Categories as we have written a PHP export which creates a file to upload all our products into their merchant / shopping tool.

    I'm more of a hack programmer than someone who knows what they are doing, but I got the new field showing on the admin product details screen, it works for both new and existing records on update, but after I have put it in I cannot copy products as duplicate. No error is generated to the user, but no details copy to the new product at all. In the cache directory I get a file showing :-

    [19-May-2012 18:38:01] PHP Warning: reset() [<a href='function.reset'>function.reset</a>]: Passed variable is not an array or object in /'admin'/includes/classes/object_info.php on line 29
    [19-May-2012 18:38:01] PHP Warning: Variable passed to each() is not an array or object in /homepages/12/d254737192/'admin'/includes/classes/object_info.php on line 30

    When I installed a different mod (MSRP) that added additional fields I had to amend 'copy_to_confirm.php' and I think ?I have to do the same to make this work again, but I am a bit lost, any pointers would be very gratefully recieved.

  3. #123
    Join Date
    May 2012
    Posts
    2
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    Quote Originally Posted by jordanfey1978 View Post
    I know this original thread is a few years old, so I'm hoping someone might still be watching it and be able to help.

    I'm currently working on my wifes shop (http://www.katiesgiftshop.co.uk) And I've added a new field for Google Categories as we have written a PHP export which creates a file to upload all our products into their merchant / shopping tool.

    I'm more of a hack programmer than someone who knows what they are doing, but I got the new field showing on the admin product details screen, it works for both new and existing records on update, but after I have put it in I cannot copy products as duplicate. No error is generated to the user, but no details copy to the new product at all. In the cache directory I get a file showing :-

    [19-May-2012 18:38:01] PHP Warning: reset() [<a href='function.reset'>function.reset</a>]: Passed variable is not an array or object in /'admin'/includes/classes/object_info.php on line 29
    [19-May-2012 18:38:01] PHP Warning: Variable passed to each() is not an array or object in /homepages/12/d254737192/'admin'/includes/classes/object_info.php on line 30

    When I installed a different mod (MSRP) that added additional fields I had to amend 'copy_to_confirm.php' and I think ?I have to do the same to make this work again, but I am a bit lost, any pointers would be very gratefully recieved.
    _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
    With a bit of homework I've managed to sort this myself, there was already some things in this forum that I had overlooked. Here is my full 'copy_to_confirm.php' file that I hope people might find interesting, please note though, there are a lot of extra fields, I have modified www.katiesgiftshop.co.uk quite a lot!

    <?php
    /**
    * @package admin
    * @copyright Copyright 2003-2009 Zen Cart Development Team
    * @copyright Portions Copyright 2003 osCommerce
    * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
    * @version $Id: copy_to_confirm.php 14139 2009-08-10 13:46:02Z wilt $
    */
    if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
    }
    if (isset($_POST['products_id']) && isset($_POST['categories_id'])) {
    $products_id = zen_db_prepare_input($_POST['products_id']);
    $categories_id = zen_db_prepare_input($_POST['categories_id']);

    // Copy attributes to duplicate product
    $products_id_from=$products_id;

    if ($_POST['copy_as'] == 'link') {
    if ($categories_id != $current_category_id) {
    $check = $db->Execute("select count(*) as total
    from " . TABLE_PRODUCTS_TO_CATEGORIES . "
    where products_id = '" . (int)$products_id . "'
    and categories_id = '" . (int)$categories_id . "'");
    if ($check->fields['total'] < '1') {
    $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "
    (products_id, categories_id)
    values ('" . (int)$products_id . "', '" . (int)$categories_id . "')");
    }
    } else {
    $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
    }
    /*Removed 27/09/2011 as part of RRP mod
    } elseif ($_POST['copy_as'] == 'duplicate') {
    $old_products_id = (int)$products_id;
    $product = $db->Execute("select products_type, products_quantity, products_model, products_image,
    products_price, products_virtual, products_date_available, products_weight,
    products_tax_class_id, manufacturers_id,
    products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute,
    product_is_free, product_is_call, products_quantity_mixed,
    product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order,
    products_price_sorter, master_categories_id
    from " . TABLE_PRODUCTS . "
    where products_id = '" . (int)$products_id . "'");
    */

    /* Removed and replaced as part of google category addition
    } elseif ($_POST['copy_as'] == 'duplicate') {
    $old_products_id = (int)$products_id;
    $product = $db->Execute("select products_type, products_quantity, products_model, products_image,
    products_price, products_msrp, products_virtual, products_date_available, products_weight,
    products_tax_class_id, manufacturers_id,
    products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute,
    product_is_free, product_is_call, products_quantity_mixed,
    product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order,
    products_price_sorter, master_categories_id
    from " . TABLE_PRODUCTS . "
    where products_id = '" . (int)$products_id . "'");
    */

    } elseif ($_POST['copy_as'] == 'duplicate') {
    $old_products_id = (int)$products_id;
    $product = $db->Execute("select p.products_type, p.products_quantity, p.products_model, p.products_image,
    p.products_price, p.products_msrp, p.products_virtual, p.products_date_available, p.products_weight,
    p.products_tax_class_id, p.manufacturers_id,
    p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
    p.product_is_free, p.product_is_call, p.products_quantity_mixed,
    p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, p.products_sort_order,
    p.products_price_sorter, p.master_categories_id, pdex.google_category
    from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_ADDITIONAL_DETAILS . " pdex
    where p.products_id = '" . (int)$products_id . "'
    and pdex.products_id = '" . (int)$products_id . "'");

    $tmp_value = zen_db_input($product->fields['products_quantity']);
    $products_quantity = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
    $tmp_value = zen_db_input($product->fields['products_price']);
    $products_price = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
    $tmp_value = zen_db_input($product->fields['products_weight']);
    $products_weight = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;



    $db->Execute("insert into " . TABLE_PRODUCTS . "
    (products_type, products_quantity, products_model, products_image, products_price, products_msrp,
    products_virtual, products_date_added, products_date_available,
    products_weight, products_status, products_tax_class_id,
    manufacturers_id,
    products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute,
    product_is_free, product_is_call, products_quantity_mixed,
    product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order,
    products_price_sorter, master_categories_id
    )
    values ('" . zen_db_input($product->fields['products_type']) . "',
    '" . $products_quantity . "',
    '" . zen_db_input($product->fields['products_model']) . "',
    '" . zen_db_input($product->fields['products_image']) . "',
    '" . $products_price . "',
    '" . zen_db_input($product->fields['products_msrp']) . "',
    '" . zen_db_input($product->fields['products_virtual']) . "',
    now(),
    '" . (zen_not_null(zen_db_input($product->fields['products_date_available'])) ? zen_db_input($product->fields['products_date_available']) : '0001-01-01 00:00:00') . "',
    '" . $products_weight . "', '0',
    '" . (int)$product->fields['products_tax_class_id'] . "',
    '" . (int)$product->fields['manufacturers_id'] . "',
    '" . zen_db_input($product->fields['products_quantity_order_min']) . "',
    '" . zen_db_input($product->fields['products_quantity_order_units']) . "',
    '" . zen_db_input($product->fields['products_priced_by_attribute']) . "',
    '" . (int)$product->fields['product_is_free'] . "',
    '" . (int)$product->fields['product_is_call'] . "',
    '" . (int)$product->fields['products_quantity_mixed'] . "',
    '" . zen_db_input($product->fields['product_is_always_free_shipping']) . "',
    '" . zen_db_input($product->fields['products_qty_box_status']) . "',
    '" . zen_db_input($product->fields['products_quantity_order_max']) . "',
    '" . zen_db_input($product->fields['products_sort_order']) . "',
    '" . zen_db_input($product->fields['products_price_sorter']) . "',
    '" . zen_db_input($categories_id) .
    "')");


    $dup_products_id = $db->Insert_ID();
    // added fields////////
    $db->Execute("insert into " . TABLE_PRODUCTS_ADDITIONAL_DETAILS. "
    (products_id, google_category )
    values ('" . (int)$dup_products_id ."', '" . zen_db_input($product->fields['google_category']) . "' )");
    // added fields////////
    $description = $db->Execute("select language_id, products_name, products_description,
    products_url
    from " . TABLE_PRODUCTS_DESCRIPTION . "
    where products_id = '" . (int)$products_id . "'");
    while (!$description->EOF) {
    $db->Execute("insert into " . TABLE_PRODUCTS_DESCRIPTION . "
    (products_id, language_id, products_name, products_description,
    products_url, products_viewed)
    values ('" . (int)$dup_products_id . "',
    '" . (int)$description->fields['language_id'] . "',
    '" . zen_db_input($description->fields['products_name']) . "',
    '" . zen_db_input($description->fields['products_description']) . "',
    '" . zen_db_input($description->fields['products_url']) . "', '0')");
    $description->MoveNext();
    }

    $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "
    (products_id, categories_id)
    values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
    $products_id = $dup_products_id;
    $description->MoveNext();
    // FIX HERE
    /////////////////////////////////////////////////////////////////////////////////////////////
    // Copy attributes to duplicate product
    // moved above $products_id_from=zen_db_input($products_id);
    $products_id_to= $dup_products_id;
    $products_id = $dup_products_id;

    if ( $_POST['copy_attributes']=='copy_attributes_yes' and $_POST['copy_as'] == 'duplicate' ) {
    // $products_id_to= $copy_to_products_id;
    // $products_id_from = $pID;
    // $copy_attributes_delete_first='1';
    // $copy_attributes_duplicates_skipped='1';
    // $copy_attributes_duplicates_overwrite='0';

    if (DOWNLOAD_ENABLED == 'true') {
    $copy_attributes_include_downloads='1';
    $copy_attributes_include_filename='1';
    } else {
    $copy_attributes_include_downloads='0';
    $copy_attributes_include_filename='0';
    }

    zen_copy_products_attributes($products_id_from, $products_id_to);
    }
    // EOF: Attributes Copy on non-linked
    /////////////////////////////////////////////////////////////////////

    // copy product discounts to duplicate
    if ($_POST['copy_discounts'] == 'copy_discounts_yes') {
    zen_copy_discounts_to_product($old_products_id, (int)$dup_products_id);
    }

    // BEGIN CEON URI MAPPING 1 of 1
    // Generate new URI mapping for this new product?
    $uri_mapping_autogen = (($_POST['uri_mapping'] == 'autogen') ? true : false);

    // Copy existing URIs from product being copied?
    $uri_mapping_copy = (($_POST['uri_mapping'] == 'copy') ? true : false);

    if ($uri_mapping_autogen || $uri_mapping_copy) {
    if ($uri_mapping_copy) {
    // Lookup and copy any URI mappings for the product be copied from
    $existing_product_uri_mappings = array();

    $existing_product_uri_mappings_sql = "
    SELECT
    language_id,
    uri
    FROM
    " . TABLE_CEON_URI_MAPPINGS . "
    WHERE
    main_page = '" . zen_db_input($zc_products->get_handler($product->fields['products_type'])) . "_info'
    AND
    associated_db_id = '" . (int) $products_id_from . "'
    AND
    current_uri = '1';";

    $existing_product_uri_mappings_result =
    $db->Execute($existing_product_uri_mappings_sql);

    while (!$existing_product_uri_mappings_result->EOF) {
    $existing_product_uri_mappings[
    $existing_product_uri_mappings_result->fields['language_id']] =
    $existing_product_uri_mappings_result->fields['uri'];

    $existing_product_uri_mappings_result->MoveNext();
    }
    }

    // Now insert the URI mappings for the new product into the database
    $languages = zen_get_languages();

    for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
    $uri_mapping = '';
    $unique_id_to_add = '';

    // Auto-generate the URI if requested
    if ($uri_mapping_autogen) {
    $uri_mapping = ceon_uri_mapping_autogen_category_or_product_uri(
    $products_id_to, 'product', null, null, $languages[$i]['code'],
    $languages[$i]['id']);
    } else {
    // Copy any URI mappings for the product be copied from, changing them slightly so
    // they are unique (in case admin user forgets to change the URI for the "new"
    // product)
    if (isset($existing_product_uri_mappings[$languages[$i]['id']])) {
    $uri_mapping = $existing_product_uri_mappings[$languages[$i]['id']];

    if (strlen($uri_mapping) > 1) {
    $unique_id_to_add = '/' . $products_id_to;
    }
    }
    }

    if (strlen($uri_mapping) > 1) {
    // Make sure URI mapping is relative to root of site and does not have more than
    // one trailing slash or any illegal characters
    $uri_mapping = ceon_uri_mapping_cleanup_uri_mapping($uri_mapping);
    }

    if ($uri_mapping != '') {
    // URI mapping does not yet exist
    $sql_data_array = array(
    'uri' => zen_db_prepare_input($uri_mapping . $unique_id_to_add),
    'date_added' => date('Y-m-d H:i:s')
    );

    $insert_sql_data = array(
    'main_page' => $zc_products->get_handler($product->fields['products_type']) .
    '_info',
    'associated_db_id' => (int) $products_id_to,
    'language_id' => (int) $languages[$i]['id'],
    'current_uri' => 1
    );

    $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

    zen_db_perform(TABLE_CEON_URI_MAPPINGS, $sql_data_array);

    // Now add the URI mappings for the review pages/tell-a-friend page for this
    // product
    if (substr($uri_mapping, -1) != '/') {
    $uri_mapping .= '/';
    }

    $sql_data_array['uri'] = zen_db_prepare_input($uri_mapping .
    CEON_URI_MAPPING_URI_PART_PRODUCT_REVIEWS . $unique_id_to_add);
    $sql_data_array['main_page'] = zen_db_prepare_input(FILENAME_PRODUCT_REVIEWS);

    zen_db_perform(TABLE_CEON_URI_MAPPINGS, $sql_data_array);

    $sql_data_array['uri'] = zen_db_prepare_input($uri_mapping .
    CEON_URI_MAPPING_URI_PART_PRODUCT_REVIEWS_INFO . $unique_id_to_add);
    $sql_data_array['main_page'] =
    zen_db_prepare_input(FILENAME_PRODUCT_REVIEWS_INFO);

    zen_db_perform(TABLE_CEON_URI_MAPPINGS, $sql_data_array);

    $sql_data_array['uri'] = zen_db_prepare_input($uri_mapping .
    CEON_URI_MAPPING_URI_PART_PRODUCT_REVIEWS_WRITE . $unique_id_to_add);
    $sql_data_array['main_page'] =
    zen_db_prepare_input(FILENAME_PRODUCT_REVIEWS_WRITE);

    zen_db_perform(TABLE_CEON_URI_MAPPINGS, $sql_data_array);

    $sql_data_array['uri'] = zen_db_prepare_input($uri_mapping .
    CEON_URI_MAPPING_URI_PART_TELL_A_FRIEND . $unique_id_to_add);
    $sql_data_array['main_page'] =
    zen_db_prepare_input(FILENAME_TELL_A_FRIEND);

    zen_db_perform(TABLE_CEON_URI_MAPPINGS, $sql_data_array);
    }
    }
    }
    // END CEON URI MAPPING 1 of 1
    }

    // reset products_price_sorter for searches etc.
    zen_update_products_price_sorter($products_id);

    }
    zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));

  4. #124
    Join Date
    Jan 2009
    Posts
    33
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    Hi I have used this thread to add extra fields and it works great, thanks.

    I was wondering if anyone could tell me how to add radio buttons. For example I am working on a site where you can book courses. I would like to add a set of radio button in the admin page where I can choose the location where the course will be held and display it. Some courses will have two locations so I thought a radio button would be best but I don't know how to go about it. The display could be something like this Location: Here, There if two were selected or just Location: Here if only one selected.

    When adding a product in admin, after adding the description there would be a set of radio buttons to select the location the course will be held in. I can just do a text field where you type the location in but I'm not sure if this is the best way because I want people to be able to search for courses held at a particular location. Not sure if its possible but I noticed you can search by manufacturer, I would like to be able to search by location. I don't need the manufacturer field so maybe there is a way I can just change it to location but some courses I would need to add two locations but now I can only add one.

    I have tried to search the forum but can't find any help so if some one can point me in the right direction it would be greatly appreciated. Hope this makes sense.

  5. #125
    Join Date
    Mar 2011
    Location
    Ireland
    Posts
    286
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    You could do search and replace on manufacturer in develop tool kit in admin pannel and change to location etc. what about using attributes for location, would have to be different locations attribute for each course? but the user would only get to choose the locations available for that course.

  6. #126
    Join Date
    Jul 2010
    Posts
    143
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    Thank you so much for such valuable post!

    I have a question.

    I need only do the step 1, 2, 7,8 if I don't need to maintain the new field at Admin?

    Is that correct?



    please help, thank all of you so much.



    1: Create a new table to hold your additional fields and give it a name i.e. products_extra_stuff and add the products_id field (so we can relate our new table to the existing products table) and whatever fields you wish to add i.e. products_colour

    2:Open includes/database_tables.php and add your new table to the list of definitions i.e.define('TABLE_PRODUCTS_EXTRA_STUFF', DB_PREFIX . 'products_extra_stuff');


    Step 7
    ...


    Step 8




    Quote Originally Posted by webego View Post
    After searching through the Zen Cart forums for help on how to add new product fields, I came across a thread started by crazy_chris which shows how to add a new field to the existing products table. Later in that thread zskiman shows how to add fields into a separate table, which is a great idea to future proof your efforts for later upgrades etc. My intention here is to share what I have learned from both these posts and add my own input which I think simplifies the end usage of your new fields.

    Any changes to existing code or completely new code are shown in red (what out for , too).

    So lets gets started...


    1. Create a new table to hold your additional fields and give it a name i.e. products_extra_stuff and add the products_id field (so we can relate our new table to the existing products table) and whatever fields you wish to add i.e. products_colour

    2. Open includes/database_tables.php and add your new table to the list of definitions i.e.define('TABLE_PRODUCTS_EXTRA_STUFF', DB_PREFIX . 'products_extra_stuff');

    3. Open admin/includes/modules/product/preview_info.php and change the following lines:

      (line 26 for me)
      p.products_sort_order, pdex.products_colour
      from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_EXTRA_STUFF . " pdex
      where p.products_id = pd.products_id and p.products_id = pdex.products_id

    4. Open admin/includes/modules/product/collect_info.php and change the following lines :

      (line 12 for me)
      $parameters = array('products_name' => '',
      'products_description' => '',

      'master_categories_id' => '',
      'products_colour' => ''

      );

      (now line 60 for me after the above edit)
      p.products_price_sorter, p.master_categories_id, pdex.products_colour
      from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
      TABLE_PRODUCTS_EXTRA_STUFF . " pdex

      where p.products_id = '" . (int)$_GET['pID'] . "'
      and p.products_id = pd.products_id and p.products_id = pdex.products_id

    5. In the same file (collect_info.php) insert your form fields to collect your new data along with the rest:

      (line 305 for me as I wanted to insert just below product name)
      <!-- BOF - Additional field added -->
      <tr>
      <td class="main"><?php echo 'Colour '; ?></td>
      <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '13') . '##' .
      zen_draw_input_field('products_colour', $pInfo->products_colour, zen_set_field_length(TABLE_PRODUCTS_EXTRA_STUFF, 'products_colour')); ?></td>
      </tr>
      <!-- EOF - Additional field added -->

    6. Open admin/includes/modules/update_product.php and add the following lines to process both new products and the editing of existing ones:

      (line 153 for me)
      ////////////// MY ADDED FIELDS ////////////////////
      $sql_data_array = array('products_colour' => zen_db_prepare_input($_POST['products_colour']));

      if ($action == 'insert_product') {
      $insert_sql_data = array('products_id' => $products_id);

      $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

      zen_db_perform(TABLE_PRODUCTS_EXTRA_STUFF, $sql_data_array);
      } elseif ($action == 'update_product') {
      zen_db_perform(TABLE_PRODUCTS_EXTRA_STUFF, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
      }
      /////////////////////////////////////////////

    7. In order to make the data from your new field(s) available to add to the product page open inludes/modules/pages/product_info/main_template_vars.php and change the following lines:

      (line 55 for me)
      p.products_discount_type, p.products_discount_type_from, p.products_sort_order,
      p.products_price_sorter, pdex.products_colour
      from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_EXTRA_STUFF . " pdex
      where p.products_status = '1'
      and p.products_id = '" . (int)$_GET['products_id'] . "'
      and pd.products_id = p.products_id and p.products_id = pdex.products_id

      (line 101 for me amongst products name, model and description)
      $products_colour = $product_info->fields['products_colour'];

    8. Finally, to display the data from your new field(s) open includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php and add something similar to the following:

      (place wherever you wish your new field to be displayed)
      <!--bof Product Colour -->
      <?php
      if ($products_colour != '') {
      ?>
      <div id="productColour" class="productGeneral"><strong>Colour: </strong><?php echo $products_colour; ?></div>
      <?php
      }
      ?>
      <!--eof Product Colour -->


    And that my friends is it...Enjoy!

  7. #127
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    67
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    Quote Originally Posted by mybiz9999 View Post
    1: Create a new table to hold your additional fields and give it a name i.e. products_extra_stuff and add the products_id field (so we can relate our new table to the existing products table) and whatever fields you wish to add i.e. products_colour
    2:Open includes/database_tables.php and add your new table to the list of definitions i.e.define('TABLE_PRODUCTS_EXTRA_STUFF', DB_PREFIX . 'products_extra_stuff');
    Zencart Version 1.5.0

    I have followed all of these instructions to the letter and got it to work. I have created two extra fields (one is products_rating and the other is products_averageprice), they both work.

    http://www.winez2u.com/index.php?mai...roducts_id=243

    I have also got it to display on the website on the product info pages (tpl_product_info_display.php) - with this code:
    <!--bof Product Average Price -->
    <?php if ($products_averageprice != '') { ?>
    <div id="productDescription" class="">
    <h3>Average Price:</h3>
    <div class="pDesc"><?php echo $products_averageprice; ?></div>
    <?php
    }
    ?>
    <!--eof Product Average Price -->

    <!--bof Product Rating -->
    <?php if ($products_rating != '') { ?>
    <div id="" class="">
    <h3>Current Rating:</h3>
    <div class="pDesc"><?php echo $products_rating; ?></div>
    <?php
    }
    ?>
    <!--eof Product Rating -->

    --------------------
    So now the next part is what has been CONFUSING me for days and I just cannot get it right.

    I want only ONE Of those extra fields to display on the product_listing page (ie. where all the products for a category come up). I am using a 4 Column Layout . I want the PRODUCTS_RATING extra field to display on each product UNDER THE PRICE (see http://www.winez2u.com/index.php?mai...ex&cPath=75_65

    I CANNOT get it to work, no matter what I try and figure I am missing something - I have tried inc/mod/mytemplate/product_listing.php but am totally LOST. On that page, I have this code in to display if column layout is selected:

    Code:
    // Following code will be executed only if Column Layout (Grid Layout) option is chosen
        if ($product_listing_layout_style == 'columns') {
          $lc_text = implode('<br />', $product_contents);
          $list_box_contents[$rows][$column] = array('params' => 'class="product-grid-list"' . ' ' , 'text' => (($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<div class="product-bg"><div class="product-topbg"><div class="featureImg1"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . $productsInCategory[$listing->fields['products_id']] . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a></div></br>') . '<div class="featureDescription1"><div class="prodtitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . $productsInCategory[$listing->fields['products_id']] . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name']. '</a></div><span class="Price">' . $lc_price . '</span></div><div class="featureButton">'.$lc_button.'</div><div class="product-bottombg">&nbsp;</div></div></div>');
    
          $column ++;
          if ($column >= PRODUCT_LISTING_COLUMNS_PER_ROW) {
            $column = 0;
            $rows ++;
          }
        }
        // End of Code fragment for Column Layout (Grid Layout) option in add on module
    PLEASE HELP, what code do I need to put in to get it to show my extra field PRODUCTS_RATING? I know it is calling from a 2nd table, and thats about it.
    Would really appreciate some help.
    Lead•Empower•Motivate
    Catherine S.
    Go2Guru

  8. #128
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    67
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    Anyone willing to help me with this - please?

    Quote Originally Posted by gandalfsmith View Post
    Zencart Version 1.5.0

    I have followed all of these instructions to the letter and got it to work. I have created two extra fields (one is products_rating and the other is products_averageprice), they both work.

    http://www.winez2u.com/index.php?mai...roducts_id=243

    I have also got it to display on the website on the product info pages (tpl_product_info_display.php) - with this code:
    <!--bof Product Average Price -->
    <?php if ($products_averageprice != '') { ?>
    <div id="productDescription" class="">
    <h3>Average Price:</h3>
    <div class="pDesc"><?php echo $products_averageprice; ?></div>
    <?php
    }
    ?>
    <!--eof Product Average Price -->

    <!--bof Product Rating -->
    <?php if ($products_rating != '') { ?>
    <div id="" class="">
    <h3>Current Rating:</h3>
    <div class="pDesc"><?php echo $products_rating; ?></div>
    <?php
    }
    ?>
    <!--eof Product Rating -->

    --------------------
    So now the next part is what has been CONFUSING me for days and I just cannot get it right.

    I want only ONE Of those extra fields to display on the product_listing page (ie. where all the products for a category come up). I am using a 4 Column Layout . I want the PRODUCTS_RATING extra field to display on each product UNDER THE PRICE (see http://www.winez2u.com/index.php?mai...ex&cPath=75_65

    I CANNOT get it to work, no matter what I try and figure I am missing something - I have tried inc/mod/mytemplate/product_listing.php but am totally LOST. On that page, I have this code in to display if column layout is selected:

    Code:
    // Following code will be executed only if Column Layout (Grid Layout) option is chosen
        if ($product_listing_layout_style == 'columns') {
          $lc_text = implode('<br />', $product_contents);
          $list_box_contents[$rows][$column] = array('params' => 'class="product-grid-list"' . ' ' , 'text' => (($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<div class="product-bg"><div class="product-topbg"><div class="featureImg1"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . $productsInCategory[$listing->fields['products_id']] . '&products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a></div></br>') . '<div class="featureDescription1"><div class="prodtitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . $productsInCategory[$listing->fields['products_id']] . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name']. '</a></div><span class="Price">' . $lc_price . '</span></div><div class="featureButton">'.$lc_button.'</div><div class="product-bottombg">&nbsp;</div></div></div>');
    
          $column ++;
          if ($column >= PRODUCT_LISTING_COLUMNS_PER_ROW) {
            $column = 0;
            $rows ++;
          }
        }
        // End of Code fragment for Column Layout (Grid Layout) option in add on module
    PLEASE HELP, what code do I need to put in to get it to show my extra field PRODUCTS_RATING? I know it is calling from a 2nd table, and thats about it.
    Would really appreciate some help.
    Lead•Empower•Motivate
    Catherine S.
    Go2Guru

  9. #129
    Join Date
    Jul 2012
    Posts
    20
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    To save time checking throught the whole thread is the initial submission the one to follow ?

    -pete

  10. #130
    Join Date
    Dec 2012
    Location
    Tampa,FL
    Posts
    25
    Plugin Contributions
    0

    Default Re: How To Add New Product Fields?

    When I need to add extra fields, there are two different plug ins that I use. One is the Products Cost Display, and the other is the UPC/ISBN extra fields. The Product Cost produces a field that only displays in admin. I use that one for the ones that I only want to display in admin. I just go through the files and change wherever the products cost is referenced and following that format, I change it to the field that I want. Then when you install the sql file, do the same thing, only in the sql file, you can also tell it where you want the field to display (after price, etc.) You just need to change the one word in the file. If I want it to also display on the front end, follow the same steps as with the Product Cost Display, only using the UPC/ISBN plug in, you can see there are a couple of other files that you need to edit. Then just following format in those files and of course replacing either upc or isbn with what ever you want. This works for fields where you want to add numerical data. To add fields where you want to add text, you need to edit the sql file. You have to make a change to Decimal and Default. To know what to put there, I just check my database, look at a text field, and use those parameters.

 

 
Page 13 of 16 FirstFirst ... 31112131415 ... LastLast

Similar Threads

  1. How to add new fields?
    By chandroo007 in forum Upgrading from 1.3.x to 1.3.9
    Replies: 1
    Last Post: 1 Jun 2010, 03:13 PM
  2. How To Add New Fields to Invoice?
    By PudzPud in forum Basic Configuration
    Replies: 7
    Last Post: 15 Nov 2009, 03:50 PM
  3. Replies: 1
    Last Post: 10 Dec 2007, 02:40 PM
  4. How to add labels to new fields
    By kappaluppa in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 3 Feb 2007, 07:16 PM
  5. How i can add new data fields to a Product
    By shreesoft in forum Customization from the Admin
    Replies: 4
    Last Post: 2 Oct 2006, 03:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR