Forums / All Other Contributions/Addons / How to Add Custom Fields for Materials & Dimensions when adding products?

How to Add Custom Fields for Materials & Dimensions when adding products?

Views: 6,753

Results 21 to 40 of 96
28 Apr 2016, 3:17 AM
#21
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

How to Add Custom Fields for Materials & Dimensions when adding products?

wmorris:

Its all there but still not working.
Okay, then did you also install the plugin's /includes/modules/pages/product_info/main_template_vars_product_type.php 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.

28 Apr 2016, 3:23 AM
#22
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

Correct, main_template_vars_product_type.php file not header_php.php file

DrByte:

Okay, then did you also install the plugin's /includes/modules/pages/product_info/main_template_vars_product_type.php file?

28 Apr 2016, 3:26 AM
#23
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

rbarbour:

Correct, main_template_vars_product_type.php file not header_php.php file

What plugins for main_template_vars_product.php?

28 Apr 2016, 3:28 AM
#24
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

wmorris:

What plugins for main_template_vars_product.php?
You said you installed the product-extra-fields plugin, right? That's where I'm quoting these from.

.
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.

28 Apr 2016, 3:32 AM
#25
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

wmorris:

What plugins for main_template_vars_product.php?

Based on what you stated in the responsive_sheffield_blue thread

wmorris:

I have made a new sql for it I enter the information into the new Materials & Dimensions in the database itself and I can't get it to echo it out on the page.

You need to add products_materials and products_dimensions to the sql query in /includes/modules/pages/product_info/main_template_vars.php

28 Apr 2016, 3:41 AM
#26
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

rbarbour:

Correct, main_template_vars_product_type.php file not header_php.php file

When I upload the main_template_vars_product_type.php from the Extra Field mod I got this error:

WARNING: An Error occurred, please refresh the page and try again.

28 Apr 2016, 3:49 AM
#27
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

Did you just blindly upload the file or did you change to include the products_materials and products_dimensions in the sql query

wmorris:

When I upload the main_template_vars_product_type.php from the Extra Field mod I got this error:

WARNING: An Error occurred, please refresh the page and try again.

28 Apr 2016, 3:53 AM
#28
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

rbarbour:

Did you just blindly upload the file or did you change to include the products_materials and products_dimensions in the sql query

No, I didn't do anything to /includes/modules/pages/product_info/main_template_vars.php

the only thing I uploaded is includes/modules/pages/product_info/main_template_vars_product_type.php

That is from download of Product Extra Field.

28 Apr 2016, 4:07 AM
#29
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

What do your error logs say

wmorris:

When I upload the main_template_vars_product_type.php from the Extra Field mod I got this error:

WARNING: An Error occurred, please refresh the page and try again.

28 Apr 2016, 4:12 AM
#30
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

rbarbour:

What do your error logs say

Its says this:

[27-Apr-2016 22:43:59 America/Chicago] Request URI: /index.php?main_page=product_info&cPath=18_23&products_id=139, IP address: 50.26.65.173
#1 require() called at [/xxxxx/xxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php:251]
#2 require(/xxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php) called at [/xxxxx/xxxxx/public_html/morrisgiftshop.biz/index.php:97]

[27-Apr-2016 22:43:59 America/Chicago] PHP Warning: require(includes/templates/template_default/templates/tpl_product_info_default.php): failed to open stream: No such file or directory in /xxxxx/xxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php on line 251
[27-Apr-2016 22:43:59 America/Chicago] Request URI: /index.php?main_page=product_info&cPath=18_23&products_id=139, IP address: 50.26.65.173
#1 require() called at [/xxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php:251]
#2 require(/xxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php) called at [/xxxxx/xxxxx/public_html/morrisgiftshop.biz/index.php:97]

[27-Apr-2016 22:43:59 America/Chicago] PHP Warning: require(includes/templates/template_default/templates/tpl_product_info_default.php): failed to open stream: No such file or directory in /xxxxx/xxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php on line 251
[27-Apr-2016 22:43:59 America/Chicago] PHP Fatal error: require(): Failed opening required 'includes/templates/template_default/templates/tpl_product_info_default.php' (include_path='.:/opt/php55/lib/php') in /xxxxx/xxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php on line 251

28 Apr 2016, 4:40 AM
#31
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

wmorris:

includes/modules/pages/product_info/main_template_vars_product_type.php

can you post that file

28 Apr 2016, 4:43 AM
#32
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

rbarbour:

can you post that file

Yes, here is the file:

<?php
/**
 * main_template_vars_product_type.php
 * This file contains all the logic to prepare $vars for use in the product-type-specific template
 * It pulls data from all the related tables which collectively store the info related only to this product type.
 *
 * @package productTypes
 * @copyright Copyright 2003-2005 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: main_template_vars_product_type.php 2326 2005-11-09 23:43:14Z drbyte $
 */
/*
 * This file contains all the logic to prepare $vars for use in the product-type-specific template
 * It pulls data from all the related tables which collectively store the info related only to this product type.
 */

  // This should be first line of the script:
  $zco_notifier->notify('NOTIFY_PRODUCT_TYPE_VARS_START_PRODUCT_EXTRA_DESCRIPTION_INFO');

/**
 * Retrieve relevant data from relational tables, for the current products_id:
 */


// Nothing special to do here for primary product_info type

    $sql = "select * from " . TABLE_PRODUCT_EXTRA_FIELDS . "
            where products_id = '" . (int)$_GET['products_id'] . "'";

    $files = $db->Execute($sql);

/*
 * extract info from queries for use as template-variables:
 */

 $extra_field  = $files->fields['extra_field'];
  $text_1  = $files->fields['text_1'];
  $text_2  = $files->fields['text_2'];
  $text_3  = $files->fields['text_3'];
  $text_4  = $files->fields['text_4'];
  $products_file_1_title = $files->fields['file_1_title'];
  $products_file_2_title = $files->fields['file_2_title'];
  $products_file_3_title = $files->fields['file_3_title'];
  $products_file_4_title = $files->fields['file_4_title'];
  $products_file_1       = $files->fields['file_1'];
  $products_file_2       = $files->fields['file_2'];
  $products_file_3       = $files->fields['file_3'];
  $products_file_4       = $files->fields['file_4'];
  $products_video       = $files->fields['video'];
  $products_video_title = $files->fields['video_title'];
if (!empty($products_video)) $products_video_link = '<a href="javascript:popupWindow(\''.zen_href_link(FILENAME_FLASH).'&id='.$_GET[products_id]. '\') ">'. $products_video_title . '</a>';
  
  if (!empty($products_file_1_title)) $products_file_1_link = '<a href="' . "product_extra_files/" . $products_file_1 . '">'. $products_file_1_title . '</a>';
  if (!empty($products_file_2_title)) $products_file_2_link = '<a href="' . "product_extra_files/" . $products_file_2 . '">'. $products_file_2_title . '</a>';
  if (!empty($products_file_3_title)) $products_file_3_link = '<a href="' . "product_extra_files/" . $products_file_3 . '">'. $products_file_3_title . '</a>';
   if (!empty($products_file_4_title)) $products_file_4_link = '<a href="' . "product_extra_files/" . $products_file_4 . '">'. $products_file_4_title . '</a>';
   


  // This should be last line of the script:
  $zco_notifier->notify('NOTIFY_PRODUCT_TYPE_VARS_END_PRODUCT_EXTRA_DESCRIPTION_INFO');
?>
28 Apr 2016, 2:35 PM
#33
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

Ok, when I stall this mod (Product Extra Field) here are the files and folders:

Admin Modified Files:
admin/includes/modules/product/collect_info.php
admin/includes/modules/product/preview_info.php
admin/includes/modules/new_product_preview.php
admin/includes/modules/update_product.php
admin/includes/modules/delete_product_confirm.php
Admin New Files:
admin/includes/extra_datafiles/product_database_names.php
admin/includes/languages/english/extra_definitions/product.php
admin/includes/functions/extra_functions/function_product_extra_fields.php

Cart Modified Files:
includes/modules/pages/product_info/main_template_vars_product_type.php
includes/templates/your_template/templates/tpl_product_info_display.php
Cart New Files:
includes/extra_datafiles/product_database_names.php
includes/modules/pages/product_info/jscript_main.js
includes/modules/popup_flash/header_php.php
includes/modules/popup_flash/jscript_AC_RunActiveContent.js
includes/modules/popup_flash/jscript_main.js
includes/templates/your_template/popup_flash/tpl_main_page.php

But when I install this file: includes/modules/pages/product_info/main_template_vars_product_type.php I was getting an error. But when I delete it off my server the error is gone.

28 Apr 2016, 2:36 PM
#34
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

Can you re-trigger the error ("Warning: an error occurred..."), and then go grab the latest debug log file? The one you posted seems to be caused by something other than this custom fields thing. Maybe multiple log files are being created on the same page. So, if you're seeing several created at the same time-stamp, post all of them. (And the ones not related to this plugin are something else you should look at fixing too.)

.
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.

28 Apr 2016, 2:43 PM
#35
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

DrByte:

Can you re-trigger the error ("Warning: an error occurred..."), and then go grab the latest debug log file? The one you posted seems to be caused by something other than this custom fields thing. Maybe multiple log files are being created on the same page. So, if you're seeing several created at the same time-stamp, post all of them. (And the ones not related to this plugin are something else you should look at fixing too.)

I did a Debug and this what I got:

[28-Apr-2016 09:39:43 America/Chicago] Request URI: /index.php?main_page=product_info&cPath=7_8&products_id=38&zenid=856a9aba017f2fea4823005914f2d625, IP address: 50.26.65.173
#1 trigger_error() called at [/xxxxx/xxxxx/public_html/morrisgiftshop.biz/includes/classes/db/mysql/query_factory.php:167]
#2 queryFactory->show_error() called at [/xxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/classes/db/mysql/query_factory.php:139]
#3 queryFactory->set_error() called at [/xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/classes/db/mysql/query_factory.php:266]
#4 queryFactory->Execute() called at [/xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/modules/pages/product_info/main_template_vars_product_type.php:31]
#5 include_once(/xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/modules/pages/product_info/main_template_vars_product_type.php) called at [/xxxxx/xxxxx/public_html/morrisgiftshop.biz/includes/modules/pages/product_info/main_template_vars.php:134]
#6 require(/xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/modules/pages/product_info/main_template_vars.php) called at [/xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php:251]
#7 require(/xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php) called at [/xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/index.php:97]

[28-Apr-2016 09:39:43 America/Chicago] PHP Fatal error: 1146:Table 'xxxxxx_zencart.TABLE_PRODUCT_EXTRA_FIELDS' doesn't exist :: select * from TABLE_PRODUCT_EXTRA_FIELDS
where products_id = '38' ==> (as called by) /xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/modules/pages/product_info/main_template_vars_product_type.php on line 31 <== in /xxxxxx/xxxxxx/public_html/morrisgiftshop.biz/includes/classes/db/mysql/query_factory.php on line 167

28 Apr 2016, 3:57 PM
#36
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

Probably all due to this error

PHP Fatal error: 1146:Table 'xxxxxx_zencart.TABLE_PRODUCT_EXTRA_FIELDS' doesn't exist

Did you run "install_product_extra_fields sql"???

Zen-Venom Get Bitten

28 Apr 2016, 4:12 PM
#37
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

kobra:

Probably all due to this error

PHP Fatal error: 1146:Table 'xxxxxx_zencart.TABLE_PRODUCT_EXTRA_FIELDS' doesn't exist

> Did you run "install_product_extra_fields sql"???

Yes, and I still getting the same error.
28 Apr 2016, 4:15 PM
#38
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

wmorris:

Yes, and I still getting the same error.
Can you now post the contents of that sql file?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Apr 2016, 4:17 PM
#39
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Location:
Amarillo, Tx
Posts:
1,683
Plugin Contributions:
0

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

mc12345678:

Can you now post the contents of that sql file?

DROP TABLE IF EXISTS product_extra_fields;
CREATE TABLE product_extra_fields (
products_id int(11) NOT NULL default '0',
extra_field text default '',
text_1 varchar(50) default NULL,
text_2 varchar(50) default NULL,
text_3 varchar(50) default NULL,
text_4 varchar(50) default NULL,
file_1 varchar(50) default NULL,
file_2 varchar(50) default NULL,
file_3 varchar(50) default NULL,
file_4 varchar(50) default NULL,
file_1_title varchar(100) default NULL,
file_2_title varchar(100) default NULL,
file_3_title varchar(100) default NULL,
file_4_title varchar(100) default NULL,
video varchar(150) default NULL,
video_title varchar(50) default NULL,
height smallint(6) default NULL,
width smallint(6) default NULL,
PRIMARY KEY (products_id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO product_extra_fields (products_id)
SELECT products_id FROM products where products_type = 1;

28 Apr 2016, 4:19 PM
#40
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: How to Add Custom Fields for Materials & Dimensions when adding products?

Verify that: includes/extra_datafiles/product_database_names.php

Has been uploaded/reupload it.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...