Linking into and out of Zen Cart
My task at hand is to link into our Zen Cart from various web sites and provide a convient way for the shopper to navigate back to the web site they started from.
I think adding a main menu "Return to..." item which is linked back to the calling web site would work well. The return url and a label would be passed as parameters to the Zen Cart. The "Return" menu item would reference this url.
I'm new to Zen Cart, so opinions on this approach are appreciated.
Based on the tutorial at http://www.zen-cart.com/wiki/index.p..._API_Tutorials I think extending the /includes/application_top.php to watch for the return url as a GET parameter is a good place to start. When a return url is detected, a "Return" menu item would be added to the main menu.
Before I get started on this, I would welcome anyones input on whether there is a simpler way, or on modifications that have already been created that I can use, or advise on the most correct places to code this customization.
Re: Linking into and out of Zen Cart
Here is how I handle returning to a previous web site from Zen Cart;
In my custom template copy of tpl_header.php, I added the following code to create a new <li> item in the navMain div. It creates a new main menu item which links to the previous web site.
<?php if ($_GET['return_url']) {
$_SESSION['return_url'] = $_GET['return_url']; }
if ($_GET['return_label']){
$_SESSION['return_label'] = $_GET['return_label']; }
if ($_SESSION['return_url']) { ?>
<li><a href="<?php echo $_SESSION['return_url']; ?>">
<?php echo ($_SESSION['return_label'] ? $_SESSION['return_label'] : 'Return ') ?></a></li>
<?php }?>
So - if the cart is called from another web site and adds the parameters return_url and return_label, a new menu item appears on the main menu. Ex:
../catalog/index.php?return_url=http://www.somesite.com&return_label=Return to SomeSite
This approach sets session variables which keep the return link on each page as the user navigates from page to page in the cart.
Peer review and critique of this code is welcome.
Re: Linking into and out of Zen Cart
Another approach would be to open the zen cart in a new window (i.e. use target="_blank" in the URL), and thus avoid this problem entirely.
Good luck,
swguy
Re: Linking into and out of Zen Cart
If you want to add static menu links to your header or footer, there is an FAQ here: https://www.zen-cart.com/tutorials/i...hp?article=234
Re: Linking into and out of Zen Cart
Quote:
Originally Posted by
somuch
Here is how I handle returning to a previous web site from Zen Cart;
This worked wonderfully, it took me a minute to realize that I had to include the return path in the link (you spelled it out, I just didn't see it) but other then that, this is an excellent trick.
Thanks for the quality post.