Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default Add Extra Product Fields using an observer

    I did a bit of code to add extra columns (mpn, ean, google_product_category) to the product table and also add the corresponding input fields for those columns in the admin product edit page.
    It uses an observer so no core file modification required.

    https://github.com/torvista/Zen_Cart...Product_Fields

    Tested on157/158 but any comments welcome. Report bugs in GitHub please.

    (If people are new to GitHub and it's use, I suggest using GitKraken and watching their video tutorials)
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

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

    Default Re: Add Extra Product Fields using an observer

    Thanks for doing this. Will add to the documentation.
    That Software Guy. My Store: Zen Cart Modifications
    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
    Mar 2004
    Posts
    201
    Plugin Contributions
    0

    Default Re: Add Extra Product Fields using an observer

    thank you so much for this.. i was wondering why i can not see the info on my product page in the front end in my catalog, thank you
    My Multi_Site Zen Carts
    http://herasonlinemarket.com

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,681
    Plugin Contributions
    123

    Default Re: Add Extra Product Fields using an observer

    You have to modify your storefront files to display as desired. This is only the admin framework for adding and updating these custom values.

    Start with includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php
    That Software Guy. My Store: Zen Cart Modifications
    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.

  5. #5
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,681
    Plugin Contributions
    123

    Default Re: Add Extra Product Fields using an observer

    That Software Guy. My Store: Zen Cart Modifications
    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.

  6. #6
    Join Date
    Mar 2004
    Posts
    201
    Plugin Contributions
    0

    Default Re: Add Extra Product Fields using an observer

    ok i understand where to put the code but not sure what to put. added to the class observer file.
    $this->extra_product_fields[] = ['name' => 'condition', 'varchar' => 20];

    AND this is from the language file
    define('PLUGIN_EXTRA_PRODUCT_FIELDS_LABEL_CONDITION', 'CONDITION');
    define('PLUGIN_EXTRA_PRODUCT_FIELDS_PLACEHOLDER_CONDITION', 'What is the condtion (New)20 characters');
    i. i want to condition to show up in the front end.

    and this is from Modify includes/modules/pages/product_info/main_template_vars.php to retrieve the field and create a variable to store it.
    $products_url = $product_info->fields['products_url'];
    $products_date_available = $product_info->fields['products_date_available'];
    $products_date_added = $product_info->fields['products_date_added'];
    $products_manufacturer = $manufacturers_name;
    $products_weight = $product_info->fields['products_weight'];
    $products_quantity = $product_info->fields['products_quantity'];
    $product_condition = $procduct_info->fields['products_condition']; <-------------This is what i added
    in this Modify includes/templates/YOURTEMPLATE/templates/tpl_product_info_display.php to show the variable.

    [QOUTE]
    <ul id="productDetailsList">
    <?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?>
    <?php echo (($flag_show_product_info_weight == 1 and $products_weight !=0) ? '<li>' . TEXT_PRODUCT_WEIGHT . $products_weight . TEXT_PRODUCT_WEIGHT_UNIT . '</li>' : '') . "\n"; ?>
    <?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; ?>
    <?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n"; ?>
    <?php echo (($flag_show_product_info_condition == 1) ? '<li>' . $products_condition . TEXT_PRODUCT_CONDITION . '</li>' : '') . "\n"; ?> <------THIS IS WHAT I ADDED..
    </ul>
    <?php
    }
    ?>
    <!--eof Product details list -->
    [/QUOTE]

    thank you in advanced
    noppie
    My Multi_Site Zen Carts
    http://herasonlinemarket.com

  7. #7
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,681
    Plugin Contributions
    123

    Default Re: Add Extra Product Fields using an observer

    You probably don't have a $flag_show_product_info_condition, so I would get rid of that conditional.

    <?php echo '<li>' . $products_condition . TEXT_PRODUCT_CONDITION . '</li>' . "\n"; ?>

    Also fix this typo:
    $product_condition = $product_info->fields['products_condition'];

    (You had it coded as $procduct_info->...)
    That Software Guy. My Store: Zen Cart Modifications
    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.

  8. #8
    Join Date
    Mar 2004
    Posts
    201
    Plugin Contributions
    0

    Default Re: Add Extra Product Fields using an observer

    ok I took out the flag statement and it still doesn't show
    My Multi_Site Zen Carts
    http://herasonlinemarket.com

 

 

Similar Threads

  1. v155 metatags overide using the notifier, to add extra fields from bookx
    By mesnitu in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 22 Sep 2016, 12:24 PM
  2. Create Account - modify existing fields or add extra fields?
    By sopretty in forum General Questions
    Replies: 4
    Last Post: 30 Jul 2010, 08:26 PM
  3. Using two modules add extra fields and recaptcha to contact form
    By webmiss in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 22 Feb 2010, 07:43 PM
  4. Using Book Product Type Extra fields (Book DD2)
    By Beau91324 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 15 Nov 2009, 08:07 PM
  5. How do I add extra images to a product using javascript
    By southernlady in forum General Questions
    Replies: 8
    Last Post: 14 Jan 2009, 08:26 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