
Originally Posted by
sammirah
If there is not a database for descriptions or if a particular field does not exist can the line be excluded from header.php? For instance the code below doesn't necessarily apply to gift cards as it does in discount coupon. Is it safe to remove it or should I change it to reflect the giftcard database just in case it effects the remaining sections?
Code:
$text_giftcards_help .= sprintf(TEXT_GIFTCARDS_HELP_NAME, $giftcards_desc->fields['giftcard_name']);
if (zen_not_null($giftcards_desc->fields['coupon_description'])) $text_coupon_help .= sprintf(TEXT_GIFTCARDS_HELP_DESC, $coupon_desc->fields['coupon_description']);
$coupon_amount = $coupon->fields['coupon_amount'];
switch ($coupon->fields['coupon_type']) {
case 'F':
$text_coupon_help .= sprintf(TEXT_GIFTCARDS_HELP_FIXED, $currencies->format($coupon->fields['coupon_amount']));
break;
case 'P':
$text_coupon_help .= sprintf(TEXT_GIFTCARDS_HELP_FIXED, number_format($coupon->fields['coupon_amount'],2). '%');
break;
case 'S':
$text_coupon_help .= TEXT_GIFTCARDS_HELP_FREESHIP;
break;
default:
}
So I found this code from ot_giftcard.php that provides information that I need in my Gift Card Lookup:
Code:
//get the activation status from the db
$giftcard_result = $db->Execute("select giftcard_active from " . TABLE_GIFTCARDS . " where giftcard_code = '" . strval($giftcard_code) . "'");
if ($giftcard_result->RecordCount() > 0)
{
if ($giftcard_result->fields['giftcard_active'] == 'Y')
{
//the card is activated
return true;
}
else
{
//the card is not activated
return false;
}
Is it possible to use the above code somewhere in the following to get the information I need to display? I am thinking I can use it in the highlighted areas of the following files.
Code:
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$text_giftcards_help = '';
if (isset($_POST['lookup_giftcards_lookup']) and $_POST['lookup_giftcards_lookup'] != '') {
// lookup requested giftcard
$giftcards = $db->Execute("select * from " . TABLE_GIFTCARDS . " where giftcard_code = '" . zen_db_input($_POST['lookup_giftcards_lookup']) . "' and giftcard_active != 'Y' ");
$_POST['lookup_giftcards_lookup'] = zen_sanitize_string($_POST['lookup_giftcards_lookup']);
if ($giftcards->RecordCount() < 1) {
// invalid giftcard code
$text_giftcards_help = sprintf(TEXT_GIFTCARDS_FAILED, zen_output_string_protected($_POST['lookup_giftcards_lookup']));
} else {
// valid giftcard code
$lookup_giftcards_id = $giftcards->fields['giftcard_id'];
$giftcards = $db->Execute("select * from " . TABLE_GIFTCARDS . " where giftcard_id = '" . (int)$lookup_giftcards_id . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'");
$text_giftcards_help = TEXT_GIFTCARDS_HELP_HEADER;
$text_giftcards_help .= sprintf(TEXT_GIFTCARDS_VALUE, $giftcards->fields['giftcard_value']);
$text_giftcards_help .= sprintf(TEXT_GIFTCARDS_BALANCE, $giftcards->format($giftcards->fields['giftcard_balance']));
$text_giftcards_help .= sprintf(TEXT_GIFTCARDS_HELP_DATE, zen_date_short($giftcards->fields['date_created']),zen_date_short($giftcards->fields['date_modified']));
}
}
// include template specific file name defines
$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_GIFTCARDS_LOOKUP, 'false');
$breadcrumb->add(NAVBAR_TITLE);
?>
or
Code:
?>
<div class="centerColumn" id="giftcardslookupInfo">
<h1 id="giftcardslookupInfoHeading"><?php echo HEADING_TITLE; ?></h1>
<div id="giftcardslookupInfoMainContent" class="content">
<?php if ((DEFINE_GIFTCARD_ACTIVE >= 1 and DEFINE_GIFTCARDS_LOOKUP_STATUS <= 2) && $text_giftcards_help == '') {
require($define_page);
} else {
echo $text_giftcards_help;
} ?>
</div>
<?php echo zen_draw_form('giftcards_lookup', zen_href_link(FILENAME_GIFTCARDS_LOOKUP, 'action=lookup', 'SSL', false)); ?>
<fieldset>
<legend><?php echo TEXT_GIFTCARDS_LOOKUP_ID_INFO; ?></legend>
<label class="inputLabel" for="lookup-giftcards-lookup"><?php echo TEXT_GIFTCARDS_LOOKUP_ID; ?></label>
<?php echo zen_draw_input_field('lookup_giftcards_lookup', $_POST['lookup_giftcards_lookup'], 'size="40" id="lookup-giftcards-lookup"');?>
</fieldset>
<?php if ($text_giftcards_help == '') { ?>
<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_LOOKUP_ALT); ?></div>
<?php } else { ?>
<div class="buttonRow forward"><?php echo '<a href="' . zen_href_link(FILENAME_GIFTCARDS_LOOKUP) . '">' . zen_image_button(BUTTON_IMAGE_CANCEL, BUTTON_CANCEL_ALT) . '</a> ' . zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_LOOKUP_ALT); ?></div>
<?php } ?>
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>
<br class="clearBoth" />
</form>
</div>
Bookmarks