Zen Follower
- Join Date:
- Aug 2011
- Posts:
- 104
- Plugin Contributions:
- 0
Embed one product's info on another's page?
I am working on converting our (rather static) asp ecommerce site to the wonder that is dynamic php (aka zencart). I'm slowly getting to be able to get it where I want, but have run into a problem implementing a very useful system on our current site into zencart.
First off, we sell model rockets. On each of our kit pages, we have a table of motors that work with the kit, giving info on the motor and expected altitude. from this table, you can click an 'add to cart' button and viola, add it to your cart without leaving the kit page.
Example here:http://www.apogeerockets.com/apprentice.asp
For the bulk kit options, I can use attributes. I would like to be able to find/write code, though, to extract the product info (price & buy-now) for the motors, though, and be able to put it in on the page.
I'm pretty new to PHP (though i'm picking it up pretty quickly!), so any shoves in the right direction to writing my own bits would be highly appreciated if no one's implemented a similar system yet. I'm guessing it has to do with the $_GET['products_id'] bit of code, exchanging the 'products_id' for '6' for example, to refer to a specific product.
And while I'm rather on the topic, I had a hiccup implementing PHP into the product description, but I seem to have fixed that and here is the solution:
Just so we're on the same page, I'm on ZC 1.3.9, I am using CKEditor, and i've managed to change the config.js to allow it to accept PHP code with the following line:
CKEDITOR.config.protectedSource.push(/<\?[\s\S]*?\?>/g);
With that addition, it no longer chews up my PHP. Huzzah. I can input PHP code using CKEditor,
For example the following code:
<?php
print "Text for Apogee Avion Rocket Kit.";
?>
In the source code for a Define page, it reads as
<div id="aboutUsMainContent" class="content">
Text for Apogee Avion Rocket Kit. </div>
To activate the ability for the php to parse within the descriptions/text boxes on the page, i followed the instructions per this thread: http://www.zen-cart.com/forum/showthread.php?t=37252&referrerid=111020
on tpl_page_default.php
<div><?php echo $var_pageDetails->fields['pages_html_text']; ?></div>
``` becomes
```html
<div><?php eval(stripslashes('?>' . $var_pageDetails->fields['pages_html_text'])); ?></div>
on tpl_product_info_display.php
<div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
``` becomes
```html
<div id="productDescription" class="productGeneral biggerText"><?php eval(stripslashes('?>' . $products_description)); ?></div>
I noticed, though, that just straight up PHP in the product description seems to trigger the "there's no text here" thing, and it won't show on the page without some plain ol' HTML in there too, outside the PHP tags.
Huzzah to figuring out that. :flex:
If there's a better known solution, though, let me know!
-e