Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Account Balance V4


sathenzar

Recommended Posts

Regaurding: http://www.oscommerce.com/community/contributions,2009

Any help would be appreciated, I've been trying to get this thing to work since 12 pm. When I copy over all the files it wants me to I get an error when going to the modules page in the admin section saying this:

 

Fatal error: Cannot redeclare class ot_account_balance in /home/sndpaint/public_html/includes/modules/order_total/ot_account_balance_org.php on line 15

 

After doing some searching I've noticed the same darn class posted in:

site root/modules/order_total/ot_account_balance.php

site root/modules/order_total/ot_account_balance_org.php

site root/languages/english/modules/order_total/ot_account_balance_org.php

 

Why is it doing this? I've tried setting it up manually from the beginning to starting over and just overwriting everything and it still gives me this error. So obviously this creator didn't realize they're importing the same code somewhere? I don't know what else to think? I've tried removing the class in one file and it just creates a whole set of other errors. Looking at the code each file seems to be the same thing...so...I'm kind of confused here.

 

Here are the 3 files:

site root/modules/order_total/ot_account_balance.php

 

<?php
/*
 $Id: ot_account_balance.php by Teddy Caddy
 made by copying:

 ot_tax.php,v 1.14 2003/02/14 05:58:35 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
 http://forums.oscommerce.de/index.php?s=&showtopic=51992&view=findpost&p=256952

*/
 class ot_account_balance {
var $title, $output;

function ot_account_balance() {
  $this->code = 'ot_account_balance';
  $this->title = MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE;
  $this->description = MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_DESCRIPTION;
  $this->enabled = ((MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_STATUS == 'true') ? true : false);
  $this->sort_order = MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_SORT_ORDER;
  $this->output = array();
}


function process () {
	global $order, $currencies, $customer_id;

$begin_account_balance_query = tep_db_query("select customers_account_balance from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$begin_account_balance_result = tep_db_fetch_array($begin_account_balance_query);
$begin_account_balance = tep_round($begin_account_balance_result['customers_account_balance'],2);

/*//	#do not show this module if account balance is zero, NULL, or negative
if (($account_balance == 0) || ($account_balance == NULL) || ($account_balance == "0.00") || ($account_balance < 0)) { 
$this->enabled = false;
}
*/
// $this->enabled = false;
if ($begin_account_balance > 0) { 
	// $this->enabled = true;

	$tax = tep_get_tax_rate(MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
	$tax_description = tep_get_tax_description(MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);

		$order->info['tax'] += tep_calculate_tax($begin_account_balance, $tax);
	 		$order->info['tax_groups']["$tax_description"] += tep_calculate_tax($begin_account_balance, $tax);

		$ot = $order->info['total']; 
		$ab = $begin_account_balance; // + tep_calculate_tax($begin_account_balance, $tax);

		if ($ot > $ab) { // Summe größer als Guthaben
		$ot -=  $ab; // + tep_calculate_tax($begin_account_balance, $tax);
		 $account_balance_zahlen = $order->info['total'] - $begin_account_balance;// Zeigt Restguthaben
		 #$account_balance_zahlen2 = $order->info['total'] - $begin_account_balance;// Zeigt Fehlbetrag
		#$account_balance = 0;
		}

		if ($ot < $ab) { //Summe kleiner als Guthaben
		$account_balance_rest = $begin_account_balance - $order->info['total'];// Zeigt Fehlbetrag

		$ot = 0;
		}

		if ($ot == $ab) {
		$ot = 0;
		$account_balance = 0;
		}



$order->info['total'] = $ot;// muß hier bleiben
// Anzeige Vorhandenes Guthaben		
	$this->output[] =  array(	   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE . ':', // Vorhandenes Guthaben
									  'text' => ''.$currencies->format($begin_account_balance, true, $order->info['currency'], $order->info['currency_value']). '',
									'value' => tep_add_tax($account_balance, $tax));
			}
# }
//  
if ($begin_account_balance > 0) {
if ($ot > $ab) { // summe größe als Guthaben
	$this->output[] =  array(	   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE_2 . ':', // noch zu Zahlen.
									  'text' => '<b>'.$currencies->format($account_balance_zahlen, true, $order->info['currency'], $order->info['currency_value']). '</b>',
									'value' => tep_add_tax($account_balance, $tax));

		}else{ 
//// 

		$this->output[] =  array(   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE_2 . ':', /// noch zu Zahlen
									  'text' => '<b>'.$currencies->format($account_balance_zahlen, true, $order->info['currency'], $order->info['currency_value']). '</b>',
									'value' => tep_add_tax($account_balance, $tax));

} 
// 
 if ($account_balance_rest > 0) {

		$this->output[] =  array(   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE_3 . ':', /// Restguthaben.
									  'text' => '<b>  '.$currencies->format($account_balance_rest, true, $order->info['currency'], $order->info['currency_value']). '</b>',
									'value' => tep_add_tax($account_balance, $tax));
									} else {
if ($account_balance_rest > 0) {
	#	 $account_balance_rest = 0;
#}	
$this->output[] =  array(   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE_4 . ':', /// Restguthaben.
									  'text' => '<b> '.$currencies->format($account_balance_rest, true, $order->info['currency'], $order->info['currency_value']). '</b>',
									'value' => tep_add_tax($account_balance, $tax));
	}	 }
		} 
}
function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }

  return $this->_check;
}

function keys() {
  return array('MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_STATUS', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_SORT_ORDER', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TAX_CLASS');
}

function install() {
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Guthaben', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_STATUS', 'true', 'Do you want to display user account balances?  This is useful for redeeming gift certificates.', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_SORT_ORDER', '3', 'Sort order of display.', '6', '2', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TAX_CLASS', '0', 'Use the following tax class on the account balance.', '6', '7', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");

}

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
 }
?>

 

site root/modules/order_total/ot_account_balance.php

 

<?php
/*
 $Id: ot_account_balance.php by Teddy Caddy
 made by copying:

 ot_tax.php,v 1.14 2003/02/14 05:58:35 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
 http://forums.oscommerce.de/index.php?s=&showtopic=51992&view=findpost&p=256952

*/
 class ot_account_balance {
var $title, $output;

function ot_account_balance() {
  $this->code = 'ot_account_balance';
  $this->title = MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE;
  $this->description = MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_DESCRIPTION;
  $this->enabled = ((MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_STATUS == 'true') ? true : false);
  $this->sort_order = MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_SORT_ORDER;
  $this->output = array();
}


function process () {
	global $order, $currencies, $customer_id;

$begin_account_balance_query = tep_db_query("select customers_account_balance from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$begin_account_balance_result = tep_db_fetch_array($begin_account_balance_query);
$begin_account_balance = tep_round($begin_account_balance_result['customers_account_balance'],2);

/*//	#do not show this module if account balance is zero, NULL, or negative
if (($account_balance == 0) || ($account_balance == NULL) || ($account_balance == "0.00") || ($account_balance < 0)) { 
$this->enabled = false;
}
*/
// $this->enabled = false;
if ($begin_account_balance > 0) { 
	// $this->enabled = true;

	$tax = tep_get_tax_rate(MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
	$tax_description = tep_get_tax_description(MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);

		$order->info['tax'] += tep_calculate_tax($begin_account_balance, $tax);
	 		$order->info['tax_groups']["$tax_description"] += tep_calculate_tax($begin_account_balance, $tax);

		$ot = $order->info['total']; 
		$ab = $begin_account_balance; // + tep_calculate_tax($begin_account_balance, $tax);

		if ($ot > $ab) { // Summe größer als Guthaben
		$ot -=  $ab; // + tep_calculate_tax($begin_account_balance, $tax);
		 $account_balance_zahlen = $order->info['total'] - $begin_account_balance;// Zeigt Restguthaben
		 #$account_balance_zahlen2 = $order->info['total'] - $begin_account_balance;// Zeigt Fehlbetrag
		#$account_balance = 0;
		}

		if ($ot < $ab) { //Summe kleiner als Guthaben
		$account_balance_rest = $begin_account_balance - $order->info['total'];// Zeigt Fehlbetrag

		$ot = 0;
		}

		if ($ot == $ab) {
		$ot = 0;
		$account_balance = 0;
		}



$order->info['total'] = $ot;// muß hier bleiben
// Anzeige Vorhandenes Guthaben		
	$this->output[] =  array(	   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE . ':', // Vorhandenes Guthaben
									  'text' => ''.$currencies->format($begin_account_balance, true, $order->info['currency'], $order->info['currency_value']). '',
									'value' => tep_add_tax($account_balance, $tax));
			}
# }
//  
if ($begin_account_balance > 0) {
if ($ot > $ab) { // summe größe als Guthaben
	$this->output[] =  array(	   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE_2 . ':', // noch zu Zahlen.
									  'text' => '<b>'.$currencies->format($account_balance_zahlen, true, $order->info['currency'], $order->info['currency_value']). '</b>',
									'value' => tep_add_tax($account_balance, $tax));

		}else{ 
//// 

		$this->output[] =  array(   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE_2 . ':', /// noch zu Zahlen
									  'text' => '<b>'.$currencies->format($account_balance_zahlen, true, $order->info['currency'], $order->info['currency_value']). '</b>',
									'value' => tep_add_tax($account_balance, $tax));

} 
// 
 if ($account_balance_rest > 0) {

		$this->output[] =  array(   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE_3 . ':', /// Restguthaben.
									  'text' => '<b>  '.$currencies->format($account_balance_rest, true, $order->info['currency'], $order->info['currency_value']). '</b>',
									'value' => tep_add_tax($account_balance, $tax));
									} else {
if ($account_balance_rest > 0) {
	#	 $account_balance_rest = 0;
#}	
$this->output[] =  array(   'title' =>  MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TITLE_4 . ':', /// Restguthaben.
									  'text' => '<b> '.$currencies->format($account_balance_rest, true, $order->info['currency'], $order->info['currency_value']). '</b>',
									'value' => tep_add_tax($account_balance, $tax));
	}	 }
		} 
}
function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }

  return $this->_check;
}

function keys() {
  return array('MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_STATUS', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_SORT_ORDER', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TAX_CLASS');
}

function install() {
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Guthaben', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_STATUS', 'true', 'Do you want to display user account balances?  This is useful for redeeming gift certificates.', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_SORT_ORDER', '3', 'Sort order of display.', '6', '2', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_ACCOUNT_BALANCE_TAX_CLASS', '0', 'Use the following tax class on the account balance.', '6', '7', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");

}

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
 }
?>

 

...I think you get the idea. I downloaded the files here: http://www.oscommerce.com/community/contributions,2009

Edited by sathenzar
Link to comment
Share on other sites

  • 2 years later...

sathenzar

 

try site root/modules/order_total

to

site root/includes/modules/order_total

 

 

My question is about the install instructions, I think they were wrong:

First:

In file catalog\admin\orders.php

Find:

case 'deleteconfirm':
   $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
   tep_remove_order($oID, $HTTP_POST_VARS['restock']);
   tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action'))));
break;

REPLACE with:

// Account Balance Modif
case 'deleteconfirm':
   $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
   tep_remove_order($oID, $HTTP_POST_VARS['restock']);

   tep_add_customer_balance($oID, $HTTP_POST_VARS['account_balance'], $cID);

   tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action'))));
break;
// End Account Balance Modif

 

then:

In file catalog\admin\orders.php

Find:

    if ($order_updated == true) {
	 $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
    } else {
	  $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
    }

    tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action')) . 'action=edit'));
    break;



Add after:

// Account Balance Modif
   case 'deleteconfirm':
       $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
       $ab = tep_db_prepare_input($HTTP_POST_VARS['account_balance']);


   if ($ab == true) {
... bla bla bla

 

case deleteconfirm appears twice, 2 times!!

In the original code the first part is deleted.

Link to comment
Share on other sites

Here is the original german forum:

 

Ref:

At the installation is no change been made so far.

was the only catalog \ includes \ modules \ order_total \ ot_account_balance.php

changed.

And adds the lang in German.

Warranty is not Accepted.

 

For more information, go to:

http://forums.oscomm...ndpost&p=257065

 

On the balance indicator in the customer account, I'm still working.

Edited by bhbilbao
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...