New Zenner
- Join Date:
- Dec 2007
- Posts:
- 69
- Plugin Contributions:
- 1
Gift Certificate Sidebox
Hiya,
I've installed a blank sidebox to show gift certificates avaliable to spend or send. I have managed to figure out how to show it only to customers logged in and not to guests browsing. But what I need it to do is show only if the customer has a gift certificate avaliable. Is this possible?
This is the code in my /modules/sideboxes/mytemplate/blank_sidebox.php
<?php /** * blank sidebox - allows a blank sidebox to be added to your site * * @package templateSystem * @copyright 2007 Kuroi Web Design * @copyright Portions Copyright 2003-2007 Zen Cart Development Team * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: blank_sidebox.php 2007-05-26 kuroi $ */ // test if box should display if (!$_SESSION['customer_id']) { $show_blank_sidebox= false; } else { $show_blank_sidebox= true; } if ($show_blank_sidebox == true) { require($template->get_template_dir('tpl_blank_sidebox.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_blank_sidebox.php'); $title = BOX_HEADING_BLANK_SIDEBOX; $title_link = false; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); } ?>
and this is my tpl_blank_sidebox.php
<?php /** * blank sidebox - allows a blank sidebox to be added to your site * * @package templateSystem * @copyright 2007 Kuroi Web Design * @copyright Portions Copyright 2003-2007 Zen Cart Development Team * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: blank_sidebox.php 2007-05-26 kuroi $ */ $content = ''; $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent"><br />'; if (isset($_SESSION['customer_id'])) { $gv_query = "select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $_SESSION['customer_id'] . "'"; $gv_result = $db->Execute($gv_query); if ($gv_result->RecordCount() && $gv_result->fields['amount'] > 0 ) { $content .= '<div id="cartBoxGVButton"><a href="' . zen_href_link(FILENAME_GV_SEND, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_SEND_A_GIFT_CERT , BUTTON_SEND_A_GIFT_CERT_ALT) . '</a></div><br />'; $content .= '<div id="cartBoxVoucherBalance">' . VOUCHER_BALANCE . '<br />' .$currencies->format($gv_result->fields['amount']) . '</div>'; } } $content .= '<img src="images/sidebox_footer.gif">'; $content .= '</div>'; ?>
Any help would be great, thanks!