Forums / General Questions / Adding Extra Fields to Product Description

Adding Extra Fields to Product Description

Views: 1,059

Results 1 to 10 of 10
14 Apr 2016, 7:48 PM
#1
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Adding Extra Fields to Product Description

Hi I have created some extra fields for the product description page which are working and populating correctly.

These are fields I've written independently, not by using a third party mod such as Numinix Product Fields.

This is the code I have in my product description which currently only displays '$products_Text_1' from the code below. How would I change this to display all fields?

<!--bof Product Texts --> <?php if ($products_Text_1 != '') { ?> <div id="productText" class="productGeneral"><strong>Text 1: </strong><a href="<?php echo $products_Text_link_1; ?>"><?php echo $products_Text_1; ?></a></div> <div id="productText" class="productGeneral"><strong>Text 2: </strong><a href="<?php echo $products_Text_link_2; ?>"><?php echo $products_Text_2; ?></a></div> <div id="productText" class="productGeneral"><strong>Text 3: </strong><a href="<?php echo $products_Text_link_3; ?>"><?php echo $products_Text_3; ?></a></div> <div id="productText" class="productGeneral"><strong>Text 4: </strong><a href="<?php echo $products_Text_link_4; ?>"><?php echo $products_Text_4; ?></a></div> <?php } ?> <!--eof Product Texts -->

Thanks

Nick

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

14 Apr 2016, 9:50 PM
#2
kobra avatar

kobra

Black Belt

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

Re: Adding Extra Fields to Product Description

I have created some extra fields for the product description page which are working and populating correctly.
which currently only displays '$products_Text_1' from the code below
You first state that they are working - then state that they are not????

Which one is it???

Well I can get you started

First you need to add fields to the table "product_description" for products_Text_1, products_Text_2, etc
keeping in mind that by default there is only "products_description text" present now you might change the naming convention to
something like

products_description text_1
products_description text_2

One then need to change the admin > includes > modules > update_product.php file about line 13

 if (isset($_POST['edit_x']) || isset($_POST['edit_y'])) {
    $action = 'new_product';
  } elseif ($_POST['products_model'] . $_POST['products_url'] . $_POST['products_name'] . $_POST['products_description'] != '')

about line 112

      $sql_data_array = array('products_name' => zen_db_prepare_input($_POST['products_name'][$language_id]),
                              'products_description' => zen_db_prepare_input($_POST['products_description'][$language_id]),
                              'products_url' => zen_db_prepare_input($_POST['products_url'][$language_id]));

In file admin > includes > modules > product > collect_info.php every line for "products_description" needs to be added to with your additional fields

All the above only gets it so one can enter in the admin the additional fields
I suspect that you have added the code you posted to includes/templates/your_template/templates/product_info_display.php which will also need to be altered

I may have missed some files that need alteration

Zen-Venom Get Bitten

14 Apr 2016, 10:11 PM
#3
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Adding Extra Fields to Product Description

What I meant is that they are working from the admin side and capturing data in the admin correctly. The first field 'products_Text_link_1' displays data inputted into the admin and pulls it correctly from the database into the front end on the product description/information page, however the code I supplied only displays 'products_Text_link_1'

And it doesn't display 'products_Text_link_2', 'products_Text_link_3', 'products_Text_link_4' etc even though data is being captured from the admin.

I suspect I need to add something in this <?php if ($products_Text_1 != '') { ?> but am unsure what I need to change to get all fields to display on the front end.

The code I have put in this post is the code I am using in the front end products description file tpl_products_description.php and that is the code I need help with. All the admin/database work has been done. Hope that makes sense?

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

14 Apr 2016, 10:34 PM
#4
kobra avatar

kobra

Black Belt

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

Re: Adding Extra Fields to Product Description

The code I have put in this post is the code I am using in the front end products description file tpl_products_description.php
Do n ot see the code you referenced???
Also, there is no file named tpl_products_description.php in a stock ZenCart fileset???

Zen-Venom Get Bitten

14 Apr 2016, 10:56 PM
#5
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Adding Extra Fields to Product Description

Sorry my error, This is the code that is in tpl_product_info_display.php

<!--bof Product Texts --> <?php if ($products_Text_1 != '') { ?> <div id="productText" class="productGeneral"><strong>Text 1: </strong><a href="<?php echo $products_Text_link_1; ?>"><?php echo $products_Text_1; ?></a></div> <div id="productText" class="productGeneral"><strong>Text 2: </strong><a href="<?php echo $products_Text_link_2; ?>"><?php echo $products_Text_2; ?></a></div> <div id="productText" class="productGeneral"><strong>Text 3: </strong><a href="<?php echo $products_Text_link_3; ?>"><?php echo $products_Text_3; ?></a></div> <div id="productText" class="productGeneral"><strong>Text 4: </strong><a href="<?php echo $products_Text_link_4; ?>"><?php echo $products_Text_4; ?></a></div> <?php } ?> <!--eof Product Texts -->

This is what I need help with so it displays the fields on the Products Description page on the front end.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

14 Apr 2016, 10:58 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Adding Extra Fields to Product Description

You say that nothing past products_links_1 displays, but when you view the source code does the remaining html appear? If so, then the issue is more likely that the variables being referenced are not being populated on the store side at the same "time" the first one is populated...

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

14 Apr 2016, 11:02 PM
#7
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Adding Extra Fields to Product Description

It doesn't matter, I've just seen my error. I hadn't put the variables into product_info/main_template_vars.php

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

14 Apr 2016, 11:02 PM
#8
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Adding Extra Fields to Product Description

I should also say I've fixed this myself :-)

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

14 Apr 2016, 11:21 PM
#9
kobra avatar

kobra

Black Belt

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

Re: Adding Extra Fields to Product Description

I hadn't put the variables into product_info/main_template_vars.php
Would this be /includes/modules/pages/product_info/main_template_vars.php

Zen-Venom Get Bitten

15 Apr 2016, 7:26 AM
#10
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Adding Extra Fields to Product Description

Yes that is correct. I'm going to stick a mod or a set of mods together anyway as it/they will be useful for certain tasks.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk