Forums / General Questions / Can we embed php in the "Product Description" box at admin > catalog > categories/..

Can we embed php in the "Product Description" box at admin > catalog > categories/..

Started by zean on 24 Feb 2016, 6:16 AM · Views: 1,254

Results 1 to 11 of 11
24 Feb 2016, 6:16 AM
#1
zean avatar

zean

Zen Follower

Join Date:
May 2009
Posts:
200
Plugin Contributions:
0

Can we embed php in the "Product Description" box at admin > catalog > categories/..

How do I embed some php in the "Product Description:" box at admin > catalog > categories/products > edit ???

Including the below in the Product Description box provides a link that displays the "Option Quantity Discounts" for the product 49.

<a href="http://mydomain/index.php?main_page=popup_attributes_qty_prices&products_id=49&products_tax_class_id=1" target="_blank">See Quantity Discounts</a>

Instead of hard coding the 49, I want to embed something like . . .

<?php echo products_id ?>

Thoughts?

24 Feb 2016, 8:45 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

Two things come to mind. There's the boilerplate software developed/discussed at software guy's site, and then there could be a "handler" page that inspects the navigation history and redirects adding the necessary information. Perhaps adding an additional flag/parameter for knowing whether to handle the uri or to process as normal. Of course the flag would be static and anyone bookmarking just from that page to that clickable link would be presented with perhaps undesirable results, unless some additional search were directed, etc...

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

24 Feb 2016, 7:14 PM
#3
zean avatar

zean

Zen Follower

Join Date:
May 2009
Posts:
200
Plugin Contributions:
0

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

Question 1. Will php code in the "Product Description" box be executed?
Question 2. What is the correct syntax?

Zencart ALREADY provides the link toward the bottom of the page with the tag and text "Quantity Discounts Available." Here's a picture . . .

Attachment 16064

which is . . .

javascript:popupWindowPrice('http://mydomain/index.php?main_page=popup_attributes_qty_prices&products_id=[B]49[/B]&products_tax_class_id=1')

I am just pasting the link into the "Product Description" box at admin > catalog > categories/products > edit

But, instead of hard-coding the **49, **I need to know if there is some way to insert code into the Product Description box so instead of . . .

products_id=[B]49[/B]

it is something like . . .

products_id=<?php echo products_id ?>

Question 1. Will php code in the "Product Description" box be executed? If anyone knows, a yes/no answer will be of great assistance.
Question 2. What is the correct syntax? If yes, I already know ```
products_id=<?php echo products_id ?>


Thanks so much.
24 Feb 2016, 7:18 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

No, php code will not be executed if added into the products description field...

That is why the previous suggestion(s) were provided.

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

24 Feb 2016, 7:29 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

To explain (wasn't asked, but)... Text entered on the admin side is prepared for database storage which converts characters such as < to something like < to put in the database, then when presented is not parsed by the php processor. But, if all of that code is modified, storage to display (or just display) then it might be possible, but also may be insecure... But, the boilerplate template code does things where it substitutes information based on a "key" and that could be used to display the "tidbit" needed to make the link complete. Otherwise, the other option described, would decrypt the current page uri and based on that information could present/process the information requested...

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

27 Feb 2016, 7:42 PM
#6
zean avatar

zean

Zen Follower

Join Date:
May 2009
Posts:
200
Plugin Contributions:
0

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

mc12345678, Great answer! Where can I send you a quick contribution for your helpful answer? Thanks so much.

29 Feb 2016, 1:21 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,139
Plugin Contributions:
56

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

What is really needed is for Zen Cart products, categories and EZ-Pages entries to support the equivalent of WordPress shortcodes.

10 Mar 2016, 9:15 PM
#9
zean avatar

zean

Zen Follower

Join Date:
May 2009
Posts:
200
Plugin Contributions:
0

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

schoolboy:

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

Great schoolboy . . . that's what I needed to get going.

Maybe to help others . . . A small addition to that doc might be . . .

In the doc http://www.thatsoftwareguy.com/zencart_php_in_description.html where it says:

If you display the Description in any of the other lists (Product Listing, New Listing, Featured Listing, All Listing), you will need to modify code that handles the product description for listing pages (in includes/modules/your_template/product_listing.php) in the same way. Alternately, you can just set "Display Product Description" to 0 on those screens (available under Admin - Configuration).

Since the code that needs modification in product_listing.php is syntactically different than in tpl_product_info_display.php . . .

In includes/modules/your_template/product_listing.php Change this . . .

$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';

to this . . .

$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes($stripped_products_description)), PRODUCT_LIST_DESCRIPTION) . '</div>';

and immediately above it add this . . .

		$products_description = zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']);
		$stripped_products_description = $products_description;
		foreach ($descr_stringlist as $varname) { 
		$stripped_products_description = str_replace($varname, constant($varname), $stripped_products_description);
		}
12 Mar 2016, 1:00 AM
#10
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

Subscribe to Scott Wilson's newsletter... over the years it's been a lifesaver for me many times!

20 years a Zencart User

14 Mar 2016, 11:03 AM
#11
cvhainb avatar

cvhainb

Zen Follower

Join Date:
Sep 2008
Posts:
212
Plugin Contributions:
19

Re: Can we embed php in the "Product Description" box at admin > catalog > categories/..

lat9:

What is really needed is for Zen Cart products, categories and EZ-Pages entries to support the equivalent of WordPress shortcodes.

Yes, I agree.

Our Site: http://zucando.com
Marketing Plugins: Marketing Modules
Free Response Templates: Responsive Templates