Zen Cart Logo
Forums / Basic Configuration / Gift Certificate Sidebox

Gift Certificate Sidebox

Locked

Views: 2,186

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
22 Sep 2008, 7:51 AM
#1
nsanford avatar

nsanford

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!

22 Sep 2008, 7:56 PM
#2
nsanford avatar

nsanford

New Zenner

Join Date:
Dec 2007
Posts:
69
Plugin Contributions:
1

Re: Gift Certificate Sidebox

Never mind...I figured out a work around for now, which is working.

22 Sep 2008, 9:59 PM
#3
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Gift Certificate Sidebox

nsanford:

Never mind...I figured out a work around for now, which is working.

And an answer to your own question might help others with the same problem.....

22 Sep 2008, 10:14 PM
#4
nsanford avatar

nsanford

New Zenner

Join Date:
Dec 2007
Posts:
69
Plugin Contributions:
1

Re: Gift Certificate Sidebox

True...
Well, I couldn't figure out how to "not" show the box if the customer didn't have any GV, so I added an else statement to tpl_blank_sidebox.php :

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>';
} **else {
  $content .= '<div id="cartBoxVoucherBalance">' .TEXT_BLANK_SIDEBOX. '</div>';**

}

then defined TEXT_BLANK_SIDEBOX in languages/english/extra_definitions/blank_sidebox_defines.php to say they have no avaliable GV.