Results 1 to 4 of 4
  1. #1

    Default Trouble adding new product fields

    Hi Guys, I am running on 1.5.6 new store and I am trying to add two new product fields. I am trying to add product_h1 and product_desc2 which will be for adding a header on the products and for adding a second description on the page. I have done the following:

    1. Added the text defnitions for the admin for both of these in admin/includes/languages/english/product.php

    2. updated admin/includes/functions/general.php to create new functions zen_get_products_h1 zen_get_products_desc2

    3. updated admin/includes/modules/product/collect_info.php for the following:

    Added below 'products_description' => '',
    Code:
      'products_h1' => '',
      'products_desc2' => '',
    Added after pd.products_description,
    Code:
    pd.products_h1, pd.products_desc2,
    Added after $products_description = isset($_POST['products_description']) ? $_POST['products_description'] : '';
    Code:
    $products_h1 = isset($_POST['products_h1']) ? $_POST['products_h1'] : '';
      $products_desc2 = isset($_POST['products_desc2']) ? $_POST['products_desc2'] : '';
    Added the following inputs for the h1 and desc2
    Code:
    <div class="form-group">
          <?php echo zen_draw_label(TEXT_PRODUCTS_H1, 'products_h1', 'class="col-sm-3 control-label"'); ?>
        <div class="col-sm-9 col-md-6">
            <?php
            for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
              ?>
            <div class="input-group">
              <span class="input-group-addon">
                  <?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>
              </span>
              <?php echo zen_draw_input_field('products_h1[' . $languages[$i]['id'] . ']', htmlspecialchars(isset($products_h1[$languages[$i]['id']]) ? stripslashes($products_h1[$languages[$i]['id']]) : zen_get_products_h1($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS_DESCRIPTION, 'products_h1') . ' class="form-control"'); ?>
            </div>
            <br>
            <?php
          }
          ?>
        </div>
      </div>
      <div class="form-group">
          <?php echo zen_draw_label(TEXT_PRODUCTS_DESC2, 'products_desc2', 'class="col-sm-3 control-label"'); ?>
        <div class="col-sm-9 col-md-6">
            <?php
            for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
              ?>
            <div class="input-group">
              <span class="input-group-addon">
                  <?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>
              </span>
              <?php echo zen_draw_textarea_field('products_desc2[' . $languages[$i]['id'] . ']', 'soft', '100%', '30', htmlspecialchars((isset($products_desc2[$languages[$i]['id']])) ? stripslashes($products_desc2[$languages[$i]['id']]) : zen_get_products_desc2($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), 'class="editorHook form-control"'); ?>
            </div>
            <br>
            <?php
          }
          ?>
        </div>
      </div>
    4. Updated admin/includes/modules/update_product.php

    added after (isset($_POST['products_model']) ? $_POST['products_model'] : '')
    Code:
     . (isset($_POST['products_h1']) ? $_POST['products_h1'] : '') . (isset($_POST['products_desc2']) ? $_POST['products_desc2'] : '')
    added after 'products_description' => zen_db_prepare_input($_POST['products_description'][$language_id]),
    Code:
    #'products_h1' => zen_db_prepare_input($_POST['products_h1'][$language_id]),
          'products_desc2' => zen_db_prepare_input($_POST['products_desc2'][$language_id]),
    5. Updated admin/includes/modules/product/preview_info.php

    added after $products_description = $_POST['products_description'];
    Code:
    $products_h1 = $_POST['products_h1'];
      $products_desc2 = $_POST['products_desc2'];
    added after pd.products_description,
    Code:
    pd.products_h1, pd.products_desc2,
    added after $pInfo->products_description = zen_get_products_description($pInfo->products_id, $languages[$i]['id']);
    Code:
    $pInfo->products_h1 = zen_get_products_h1($pInfo->products_id, $languages[$i]['id']);
            $pInfo->products_desc2 = zen_get_products_desc2($pInfo->products_id, $languages[$i]['id']);
    added after $pInfo->products_description = zen_db_prepare_input($products_description[$languages[$i]['id']]);
    Code:
    $pInfo->products_h1 = zen_db_prepare_input($products_h1[$languages[$i]['id']]);
            $pInfo->products_desc2 = zen_db_prepare_input($products_desc2[$languages[$i]['id']]);
    6. added two new columns in the product_description table names products_h1 and products_desc2

    I feel like I could be missing something, Everything displays correctly on the admin side, the inputs show correctly. If I manually enter the products_h1 and products_desc2 in phpmyadmin they will show on the admin when I try alter the product, however as soon as I try update the product these will be rewritten with blanks. Can anyone see anything?

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,759
    Plugin Contributions
    124

    Default Re: Trouble adding new product fields

    If these are HTML fields, you have to add them to the sanitizer's exclusion list.
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #3
    Join Date
    Jan 2004
    Posts
    66,380
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Trouble adding new product fields

    In preview_info.php did you also add your new fields to match the zen_draw_hidden_field calls done later in the file?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4

    Default Re: Trouble adding new product fields

    Thanks guys, you were both completely correct!

    I have added the description to the file admin/includes/init_includes/init_sanatize.php and I have also added the zen_draw_hidden fields!

    All works perfectly now!

 

 

Similar Threads

  1. v155 Adding New Fields to the Music Product Type that Display on Store Pages
    By Joseph M in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 12 Aug 2018, 11:07 PM
  2. v151 Having trouble with prices after adding new product
    By KNM Computers in forum Setting Up Categories, Products, Attributes
    Replies: 10
    Last Post: 3 Dec 2012, 07:37 PM
  3. Help with adding new fields for product in admin?
    By eb_dev in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 28 Jan 2011, 03:11 PM
  4. Adding New Product Fields
    By mask2011 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 19 Jul 2010, 05:56 PM

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