Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Missing an Error Message


jack_frost

Recommended Posts

a Little mix-up from all the unwanted error messages, i actually want one that is not showing! (Typical)

 

I have Installed CCGV(Trad) and in the Checkout_Payment section of the whole, the costumer can choose to redeem a Coupon!.

 

Upon doing so. the costumer does not get a warning if the coupon is invalid, nor does he get one saying that it was valid. only in the Url. it says "http://fatima.dk/osc/checkout_payment.php?error_message=Wrong+Code"

 

The Error Message should show in the top as a red bar according to the CCGV(trad) forum. also they say that its a Server Specific, and therefor has nothing to do with the CCGV Contrib.

 

How do i get it to show?. or is it possible to Create the Warning as a popup instead (Like most of the other warnings on my site, e.g when no payment option is selected).

 

Posted below are my Checkout_Payment.php and includes/classes/Order_total.php (Edits for the CCGV have a //CCGV at the end of each line)

 

Checkout_Payment.php:

 

<?php
/*
 $Id: checkout_payment.php,v 1.113 2003/06/29 23:03:27 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

// if there is nothing in the customers cart, redirect them to the shopping cart page
 if ($cart->count_contents() < 1) {
tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

// if no shipping method has been selected, redirect the customer to the shipping method selection page
 if (!tep_session_is_registered('shipping')) {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 }

// avoid hack attempts during the checkout procedure by checking the internal cartID
 if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
if ($cart->cartID != $cartID) {
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
}
 }
// if we have been here before and are coming back get rid of the credit covers variable
if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');  //CCGV

// Stock Check
 if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
  if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
	tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
	break;
  }
}
 }

// if no billing destination address was selected, use the customers own address as default
 if (!tep_session_is_registered('billto')) {
tep_session_register('billto');
$billto = $customer_default_address_id;
 } else {
// verify the selected billing address
$check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'");
$check_address = tep_db_fetch_array($check_address_query);

if ($check_address['total'] != '1') {
  $billto = $customer_default_address_id;
  if (tep_session_is_registered('payment')) tep_session_unregister('payment');
}
 }

 require(DIR_WS_CLASSES . 'order.php');
 $order = new order;
 require(DIR_WS_CLASSES . 'order_total.php');// CCGV
$order_total_modules = new order_total;// CCGV
 if (!tep_session_is_registered('comments')) tep_session_register('comments');

 $total_weight = $cart->show_weight();
 $total_count = $cart->count_contents();
$total_count = $cart->count_contents_virtual(); // CCGV

// load all enabled payment modules
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment;

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PAYMENT);

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
var selected;
<?php /* following jscript function ADDED FOR CCGV */ ?>
var submitter = null;
function submitFunction() {
  submitter = 1;
  }
<?php /* END OF ADDED FOR CCGV */ ?>
function selectRowEffect(object, buttonSelect) {
 if (!selected) {
if (document.getElementById) {
  selected = document.getElementById('defaultSelected');
} else {
  selected = document.all['defaultSelected'];
}
 }

 if (selected) selected.className = 'moduleRow';
 object.className = 'moduleRowSelected';
 selected = object;

// one button is not an array
 if (document.checkout_payment.payment[0]) {
document.checkout_payment.payment[buttonSelect].checked=true;
 } else {
document.checkout_payment.payment.checked=true;
 }
}

function rowOverEffect(object) {
 if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
 if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}
//--></script>
<?php echo $payment_modules->javascript_validation(); ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) {

?> 
<tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main"><b><?php echo tep_output_string_protected($error['title']); ?></b></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBoxNotice">
	  <tr class="infoBoxNoticeContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main" width="100%" valign="top"><?php echo tep_output_string_protected($error['error']); ?></td>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main"><b><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></b></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
			<td class="main" width="50%" valign="top"><?php echo TEXT_SELECTED_BILLING_DESTINATION; ?><br><br><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td>
			<td align="right" width="50%" valign="top"><table border="0" cellspacing="0" cellpadding="2">
			  <tr>
				<td class="main" align="center" valign="top"><b><?php echo TITLE_BILLING_ADDRESS; ?></b><br><?php echo tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
				<td class="main" valign="top"><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br>'); ?></td>
				<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
			  </tr>
			</table></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main"><b><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></b></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 $selection = $payment_modules->selection();

 if (sizeof($selection) > 1) {
?>
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main" width="50%" valign="top"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></td>
			<td class="main" width="50%" valign="top" align="right"><b><?php echo TITLE_PLEASE_SELECT; ?></b><br><?php echo tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></td>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
<?php
 } else {
?>
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main" width="100%" colspan="2"><?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?></td>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
<?php
 }

 $radio_buttons = 0;
 for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
?>
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
  echo '				  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
} else {
  echo '				  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
}
?>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
				<td class="main" align="right">
<?php
if (sizeof($selection) > 1) {
  echo tep_draw_radio_field('payment', $selection[$i]['id']);
} else {
  echo tep_draw_hidden_field('payment', $selection[$i]['id']);
}
?>
				</td>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			  </tr>
<?php
if (isset($selection[$i]['error'])) {
?>
			  <tr>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				<td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			  </tr>
<?php
} elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
?>
			  <tr>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				<td colspan="4"><table border="0" cellspacing="0" cellpadding="2">
<?php
  for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>
				  <tr>
					<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
					<td class="main"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>
					<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
					<td class="main"><?php echo $selection[$i]['fields'][$j]['field']; ?></td>
					<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				  </tr>
<?php
  }
?>
				</table></td>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			  </tr>
<?php
}
?>
			</table></td>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
<?php
$radio_buttons++;
 }
?>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 echo $order_total_modules->credit_selection();// CCGV
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="main"><b><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></td>
			<td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
			<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
		  </tr>
		</table></td>
		<td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
			<td><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
			<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
		  </tr>
		</table></td>
		<td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
		<td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
			<td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
		<td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
		<td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
		<td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
	  </tr>
	</table></td>
  </tr>
</table></form></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

And Order_total.php:

 

<?php
/*
 $Id: order_total.php,v 1.4 2003/02/11 00:04:53 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class order_total {
var $modules;

// class constructor
function order_total() {
  global $language;

  if (defined('MODULE_ORDER_TOTAL_INSTALLED') && tep_not_null(MODULE_ORDER_TOTAL_INSTALLED)) {
	$this->modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED);

	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  include(DIR_WS_LANGUAGES . $language . '/modules/order_total/' . $value);
	  include(DIR_WS_MODULES . 'order_total/' . $value);

	  $class = substr($value, 0, strrpos($value, '.'));
	  $GLOBALS[$class] = new $class;
	}
  }
}

function process() {
  $order_total_array = array();
  if (is_array($this->modules)) {
	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ($GLOBALS[$class]->enabled) {
		$GLOBALS[$class]->process();

		for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
		  if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
			$order_total_array[] = array('code' => $GLOBALS[$class]->code,
										 'title' => $GLOBALS[$class]->output[$i]['title'],
										 'text' => $GLOBALS[$class]->output[$i]['text'],
										 'value' => $GLOBALS[$class]->output[$i]['value'],
										 'sort_order' => $GLOBALS[$class]->sort_order);
		  }
		}
	  }
	}
  }

  return $order_total_array;
}

function output() {
  $output_string = '';
  if (is_array($this->modules)) {
	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ($GLOBALS[$class]->enabled) {
		$size = sizeof($GLOBALS[$class]->output);
		for ($i=0; $i<$size; $i++) {
		  $output_string .= '			  <tr>' . "\n" .
							'				<td align="right" class="main">' . $GLOBALS[$class]->output[$i]['title'] . '</td>' . "\n" .
							'				<td align="right" class="main">' . $GLOBALS[$class]->output[$i]['text'] . '</td>' . "\n" .
							'			  </tr>';
		}
	  }
	}
  }

  return $output_string;
}
// CCGV - START ADDITION
//
// This function is called in checkout payment after display of payment methods. It actually calls
// two credit class functions.
//
// use_credit_amount() is normally a checkbox used to decide whether the credit amount should be applied to reduce
// the order total. Whether this is a Gift Voucher, or discount coupon or reward points etc.
//
// The second function called is credit_selection(). This in the credit classes already made is usually a redeem box.
// for entering a Gift Voucher number. Note credit classes can decide whether this part is displayed depending on
// E.g. a setting in the admin section.
//
function credit_selection() {
  $selection_string = '';
  $close_string = '';
  $credit_class_string = '';
  if (MODULE_ORDER_TOTAL_INSTALLED) {
	$header_string = '<tr>' . "\n";
	$header_string .= '   <td><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n";
	$output1_string .= '	  <tr>' . "\n";
	$header_string .= '		<td class="main"><b>' . TABLE_HEADING_CREDIT . '</b></td>' . "\n";
	$header_string .= '	  </tr>' . "\n";
	$header_string .= '	</table></td>' . "\n";
	$header_string .= '  </tr>' . "\n";
	$header_string .= '<tr>' . "\n";
	$header_string .= '   <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">' . "\n";
	$header_string .= '	 <tr class="infoBoxContents"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">' ."\n";
   $header_string .= '	   <tr><td width="10">' .  tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' . "\n";
	$header_string .= '		   <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n";
	$close_string   = '						   </table></td>';
	$close_string  .= '<td width="10">' .  tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
	$close_string  .= '</tr></table></td></tr></table></td>';
	$close_string  .= '<tr><td width="100%">' .  tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>';
	reset($this->modules);
	$output_string = '';
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) {
		$use_credit_string = $GLOBALS[$class]->use_credit_amount();
		if ($selection_string =='') $selection_string = $GLOBALS[$class]->credit_selection();
		if ( ($use_credit_string !='' ) || ($selection_string != '') ) {
		  $output_string .=  '<tr colspan="4"><td colspan="4" width="100%">' .  tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>';
		  $output_string = ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" >' . "\n" .
						   '   <td width="10">' .  tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' .
						   '	 <td class="main"><b>' . $GLOBALS[$class]->header . '</b></td>' . $use_credit_string;
		  $output_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
		  $output_string .= '  </tr>' . "\n";
		  $output_string .= $selection_string;
		}

	  }
	}
	if ($output_string != '') {
	  $output_string = $header_string . $output_string;
	  $output_string .= $close_string;
	}
  }
  return $output_string;
}


//			if ($selection_string !='') {
//			  $output_string .= '</td>' . "\n";
//			  $output_string .= $selection_string;
//			}




// update_credit_account is called in checkout process on a per product basis. It's purpose
// is to decide whether each product in the cart should add something to a credit account.
// e.g. for the Gift Voucher it checks whether the product is a Gift voucher and then adds the amount
// to the Gift Voucher account.
// Another use would be to check if the product would give reward points and add these to the points/reward account.
//
function update_credit_account($i) {
  if (MODULE_ORDER_TOTAL_INSTALLED) {
	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
		$GLOBALS[$class]->update_credit_account($i);
	  }
	}
  }
}
// This function is called in checkout confirmation.
// It's main use is for credit classes that use the credit_selection() method. This is usually for
// entering redeem codes(Gift Vouchers/Discount Coupons). This function is used to validate these codes.
// If they are valid then the necessary actions are taken, if not valid we are returned to checkout payment
// with an error
//
function collect_posts() {
  global $HTTP_POST_VARS,$HTTP_SESSION_VARS;
  if (MODULE_ORDER_TOTAL_INSTALLED) {
	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
		$post_var = 'c' . $GLOBALS[$class]->code;
		if ($HTTP_POST_VARS[$post_var]) {
							if (!tep_session_is_registered($post_var)) tep_session_register($post_var);
						$post_var = $HTTP_POST_VARS[$post_var];
					}
		$GLOBALS[$class]->collect_posts();
	  }
	}
  }
}
// pre_confirmation_check is called on checkout confirmation. It's function is to decide whether the
// credits available are greater than the order total. If they are then a variable (credit_covers) is set to
// true. This is used to bypass the payment method. In other words if the Gift Voucher is more than the order
// total, we don't want to go to paypal etc.
//
function pre_confirmation_check() {
  global $payment, $order, $credit_covers;
  if (MODULE_ORDER_TOTAL_INSTALLED) {
	$total_deductions  = 0;
	reset($this->modules);
	$order_total = $order->info['total'];
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  $order_total = $this->get_order_total_main($class,$order_total);
	  if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
		$total_deductions = $total_deductions + $GLOBALS[$class]->pre_confirmation_check($order_total);
		$order_total = $order_total - $GLOBALS[$class]->pre_confirmation_check($order_total);
	  }
	}
	if ($order->info['total'] - $total_deductions <= 0 ) {
				if(!tep_session_is_registered('credit_covers')) tep_session_register('credit_covers');
	  $credit_covers = true;
	}
			else{   // belts and suspenders to get rid of credit_covers variable if it gets set once and they put something else in the cart
				if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');	
			}
  }
}
// this function is called in checkout process. it tests whether a decision was made at checkout payment to use
// the credit amount be applied aginst the order. If so some action is taken. E.g. for a Gift voucher the account
// is reduced the order total amount.
//
function apply_credit() {
  if (MODULE_ORDER_TOTAL_INSTALLED) {
	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
		$GLOBALS[$class]->apply_credit();
	  }
	}
  }
}
// Called in checkout process to clear session variables created by each credit class module.
//
function clear_posts() {
  global $HTTP_POST_VARS,$HTTP_SESSION_VARS;
  if (MODULE_ORDER_TOTAL_INSTALLED) {
	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
		$post_var = 'c' . $GLOBALS[$class]->code;
			if (tep_session_is_registered($post_var)) tep_session_unregister($post_var);
	  }
	}
  }
}
// Called at various times. This function calulates the total value of the order that the
// credit will be appled aginst. This varies depending on whether the credit class applies
// to shipping & tax
//
function get_order_total_main($class, $order_total) {
  global $credit, $order;
//	  if ($GLOBALS[$class]->include_tax == 'false') $order_total=$order_total-$order->info['tax'];
//	  if ($GLOBALS[$class]->include_shipping == 'false') $order_total=$order_total-$order->info['shipping_cost'];
  return $order_total;
}
// CCGV - END ADDITION

 }
?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...