Zen Cart Logo
Forums / Zen Cart Code Suggestions / Adding Text to Item Description

Adding Text to Item Description

Locked

Views: 264

Results 1 to 20 of 31
This thread is locked. New replies are disabled.
1 Oct 2010, 1:01 PM
#1
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Adding Text to Item Description

I would like to suggest that there be some way while adding an item to select from something like a drop down to pull in static text that is stored. Example would be perhaps something like information that is common amoung items that cutting and pasting can be elliminated.

1 Oct 2010, 2:50 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Adding Text to Item Description

Something like this would give you total control over that for use in ALL your applications:
http://www.clipmenu.com/

I'm sure there are zillions of similar apps for windoze if you're unfortunate enough to still use that.

1 Oct 2010, 7:48 PM
#4
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

Thanks Dr. Byte I'm running windows and it appears that the program you recommended is only for MAC. However, I am going to work on the other suggestion that SWGuy gave me as I believe that will for me.

I really appreciate the help!

2 Oct 2010, 9:02 PM
#5
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

Hi,

I got your variable method to work when I type in the variable and it pulls in the text from my_defines.php.

However, I like your idea of placing text into a category ID - in my case I believe it is Category ID 1. when I create the CAT1_DESC with my_defines.php the text is not being inserted into Category 1. Can you possibly show me what an exampole of CAT1_DESC would look like in the my_defines.php file?

Thanks Jeff

3 Oct 2010, 5:31 AM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,695
Plugin Contributions:
56

Re: Adding Text to Item Description

If you followed the example I gave and it didn't work, the mostly likely reason is that the $current_category_id isn't what you think it is. Try printing it out to see the real value.

3 Oct 2010, 12:09 PM
#7
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

I'm still a novice here - can you tell me how to print it out? I tried placing the $current_category_id in the item description with and without the $ and nothing appeared.

I would like to do this=> If you just want to add some boilerplate text based on category, product name, or some other field, you can do that too, without having to type it in to each product in the Admin interface. For instance, here's some logic that adds the string CAT1_DESC (which you have defined in the file includes/languages/english/extra_definitions/my_defines.php) to every product in category 1:

This is what my_defines.php looks like.

<?php $descr_stringlist = array("CAT1_DESC"); define('CAT1_DESC', ' <br> <b>Item Condition and Grading Criteria</b><br> <br> <br> <b>LIKE NEW / EXCELLENT</b> - Near-perfect and free of defects. No tears, no stains, corners must be mostly sharp, some handling wear is allowed. May have original music store stamp, but no extraneous pen or pencil markings. <br> <br> <b>VERY GOOD</b> - A piece with only slight defects. Edges and corners can show some light wear but no tears greater than 1/2 inch. Some light handling wear and/or soiling and/or creases. Stains and other damage are not allowed. May have a music store stamp, label or owner’s name written on cover <br> <br> <b>GOOD</b> - Defects can include handling wear, edge and corner wear, light creases, tears up to 1”, a light water stain (but no damage), up to 50% spine separation, writing, a label, or a store stamp on the cover, or other minor defects. Can be mended inside with tape - no tape on cover. <br> <br> <b>FAIR</b> - Defects can include handling wear, significant edge and corner wear, creases, writing, chipping, 100% spine split, Staples and/or tape on the cover or inside. But still 100% legible and complete. <br> <br> <b>POOR</b> - Can be torn, ragged, mended, stained, stapled, etc. Larger sizes maybe clipped making some of the contents illegible. ') ?>

I appreciate any help - Thanks Jeff

3 Oct 2010, 12:53 PM
#8
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Adding Text to Item Description

For windows users, check this free clipboard manager:

http://www.3dclipboard.net/

3 Oct 2010, 3:00 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding Text to Item Description

One way of printing out $current_category_id would be to add a debug line inside the file PHP code (not in the description content) after $current_category_id is assigned a value, like this

echo 'ccid= ' . $current_category_id;//debug

Then you would see somewhere on the screen (probably above the description)

ccid= 23

3 Oct 2010, 4:03 PM
#10
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

I'm not sure where to put this debug code

echo 'ccid= ' . $current_category_id;

<!--bof Product description --> <?php if (($products_description != '') || ($current_category_id == 1) ) { ?> <div id="productDescription" class="productGeneral biggerText"> <?php $stripped_products_description = $products_description; if ($current_category_id == 1) { $stripped_products_description = $stripped_products_description . CAT1_DESC; } echo stripslashes($stripped_products_description); echo '</div>'; ?> <?php} ?> <!--eof Product description -->
3 Oct 2010, 5:06 PM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding Text to Item Description

Since $current_category_id is an outside value used by the boilerplate code, I would put the debug right after

<?php if (($products_description != '') || ($current_category_id == 1) ) { ?>

<?php echo 'ccid= ' . $current_category_id; ?>
3 Oct 2010, 5:19 PM
#12
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

I really appreciate the help but I still see nothing even remote to a category ID when placing the debug as suggested - could you please review what I've done by modifying the tpl_product_info_display.php

<!--bof Product description --> <?php if (($products_description != '') || ($current_category_id == 1) ) { ?> <?php echo 'ccid= ' . $current_category_id; ?> <div id="productDescription" class="productGeneral biggerText"> <?php $stripped_products_description = $products_description; if ($current_category_id == 1) { $stripped_products_description = $stripped_products_description . CAT1_DESC; } echo stripslashes($stripped_products_description); echo '</div>'; ?> <?php } ?> <!--eof Product description -->
3 Oct 2010, 5:27 PM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding Text to Item Description

Maybe put the debug before the if test:

<?php echo 'ccid= ' . $current_category_id; ?> <?php if (($products_description != '') || ($current_category_id == 1) ) { ?>

The test is set to display the description if there is a description, OR if ccid is 1, but it couldn't hurt to output the debug before the test.

I'm not sure that code is really the right thing to put in tpl_product_info_display.php - it might be that $current_category_id has no value in that page. I couldn't be sure without reviewing the original code.

3 Oct 2010, 7:59 PM
#14
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

Yes that worked!! Thank you!

:clap::clap::clap:

3 Oct 2010, 8:04 PM
#15
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

swguy:

I wrote a tutorial on doing this using PHP with the Zen Cart languages files:

http://www.thatsoftwareguy.com/zencart_php_in_description.html

Okay now that I can see what the CCID is for every product/item - how can I make a whole category for example on my website https://www.vintagecollectionsonline.com - I would like every item under sheet music to have a block of text inserted permaninatly but if just displaying is what I can get for now that still would be good.

Thanks for any help.

4 Oct 2010, 12:42 AM
#16
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding Text to Item Description

Current category id is going to be useless for you, because the actual category the product is in will be one of dozens or hundreds of subcategories of Sheet Music (category id 1). What you will need to do is test for the top category id == 1.

(int)$GET['cPath'] == 1
This will strip the cPath string down to the first number before any
```php

<!--bof Product description --> <?php if (($products_description != '') || ((int)$_GET['cPath'] == 1) ) { ?> <div id="productDescription" class="productGeneral biggerText"> <?php $stripped_products_description = $products_description; if ((int)$_GET['cPath'] == 1) { $stripped_products_description = $stripped_products_description . CAT1_DESC; } echo stripslashes($stripped_products_description); echo '</div>'; ?> <?php} ?> <!--eof Product description -->
4 Oct 2010, 12:08 PM
#17
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

Oh, I do agree with you - I need to know that I am in fact latching on to the higher level category in order that I display my constant message. Question - will that message be inserted into the descritpion of the item or just display when the item is brought up? Is there a way to place the text into the descrition once we get the test complete?

I wish I could say that worked but it now does not display any item descrition information at all - just a blank middle area. :-(

<!--bof Product description --> <?php if (($products_description != '') || ((int)$_GET['cPath'] == 1) ) { ?> <div id="productDescription" class="productGeneral biggerText"> <?php $stripped_products_description = $products_description; if ((int)$_GET['cPath'] == 1) { $stripped_products_description = $stripped_products_description . CAT1_DESC; } echo stripslashes($stripped_products_description);

echo '</div>';
?>

<?php} ?> <!--eof Product description -->
4 Oct 2010, 12:14 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding Text to Item Description

Try another debug line to see what you are actually getting:```php

<!--bof Product description --> <?php echo 'top cat = ' . (int)$_GET['cPath'];//debug ?> <?php if (($products_description != '') || ((int)$_GET['cPath'] == 1) ) { ?>

This kind of code cannot insert the boilerplate into the actual description, which is stored in the database. And there is no point to having it stored there, since it is always the same - you are better off having it displayed at runtime, where it can be updated for all products at once if ever necessary.
4 Oct 2010, 12:23 PM
#19
jfreeman avatar

jfreeman

Zen Follower

Join Date:
Apr 2010
Location:
Sutton, MA
Posts:
150
Plugin Contributions:
0

Re: Adding Text to Item Description

still nothing pulls up when I click in an item - just a blank middle part under the item name:

ex: Home :: Sheet Music :: 1941 - 1950 :: Religious :: A Wonderful Time Up There

Then nothing below.

4 Oct 2010, 1:50 PM
#20
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Adding Text to Item Description

Do you have the debug line active now? That should display regardless of whether the description shows up. What does that section of your file look like now?

I notice that the line formatting is gone from your code in the post above. That wouldn't cause a problem by itself, as PHP depends on the semicolon ; to designate statements, but it might be a symptom of some editing problem.