Jump to content



Photo
- - - - -

[Contribution] Upgrading osC from 2.2 MS2 to 2.2 RC2a


  • Please log in to reply
111 replies to this topic

#21   Jan Zonjee

Jan Zonjee

    Governor of Peace

  • Core Team
  • 7,093 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 20 June 2009 - 18:04

Should this issue be logged as a bug of R2a?

No, this contribution is buggy in 2.2RC2a. When changing a couple of things I could make this work. For starters I found the module is not added to the configuration value for MODULE_ORDER_TOTAL_INSTALLED. So I added it manually (table configuration).

Then in includes/modules/ot_fixed_payment_chg.php both the function calculate_credit() and get_payment_cost() return nothing when there is no tax class set.
So I changed both bottom parts of those function to:
} else {
			$od_amount = $od_am;
		  }
		}
	  }
	  return $od_amount;
	}
Then I changed the function selection in includes/classes/payment.php to:
function selection() {
	  $selection_array = array();
	  global $language;
	  include_once (DIR_WS_MODULES.'order_total/ot_fixed_payment_chg.php'); // added for ot_fixed_payment_chg
	  include_once(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_fixed_payment_chg.php');
	  $GLOBALS['ot_fixed_payment_chg'] = new ot_fixed_payment_chg; // added for ot_fixed_payment_chg
	  if (is_array($this->modules)) {
		reset($this->modules);
		while (list(, $value) = each($this->modules)) {
		  $class = substr($value, 0, strrpos($value, '.'));
		  if ($GLOBALS[$class]->enabled) {
			$selection = $GLOBALS[$class]->selection();
			$selection['cost'] = $GLOBALS['ot_fixed_payment_chg']->get_payment_cost($class); // added for ot_fixed_payment_chg
			if (is_array($selection)) $selection_array[] = $selection;
		  }
		}
	  }
	  return $selection_array;
	}


#22   solosc

solosc
  • Members
  • 10 posts
  • Real Name:Sebastiaan

Posted 22 June 2009 - 19:18

I noticed that the ot_fixed_payment_chg.php file I have been using is different, so just to be sure I downloaded the contrib again and first followed the instructions. Installed ok, but not displayed on checkout_confirmation.

Once I complete your steps (especially the proposed change in ot_fixed_payment_chg.php) I get error in admin:
Parse error: syntax error, unexpected $end in /home/id03648/domains/wuite.net/public_html/includes/modules/order_total/ot_fixed_payment_chg.php on line 164
in the order total overview page.

One step I didn't do yet and that is "added to the configuration value for MODULE_ORDER_TOTAL_INSTALLED". Could you tell me how this entry should look like exactly please? Not sure if this is the cause for the above error.

My ot_fixed_payment_chg.php looks like this now:

<?php
/*
  $Id: ot_fixed_payment_chg.php,v 2.1 2006 xaglo Exp $
  * Order total module that displays the fee related to the payment type.
  * A method exists to allow the display of the fee from the payment type page

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

  Copyright (c) 2004 osCommerce

  Released under the GNU General Public License
  * Modified by rigadin@osc-help.net to get it working with tax class
  * Modified by Giovanni Putignano (gputignano@tiscali.it), now display taxes correctly.
*/

  class ot_fixed_payment_chg {
	var $title, $output;

	function ot_fixed_payment_chg() {
	  $this->code = 'ot_fixed_payment_chg';
	  $this->title = MODULE_FIXED_PAYMENT_CHG_TITLE;
	  $this->description = MODULE_FIXED_PAYMENT_CHG_DESCRIPTION;
	  $this->enabled = MODULE_FIXED_PAYMENT_CHG_STATUS;
	  $this->sort_order = MODULE_FIXED_PAYMENT_CHG_SORT_ORDER;
	  $this->type = MODULE_FIXED_PAYMENT_CHG_TYPE;
	  $this->tax_class = MODULE_FIXED_PAYMENT_CHG_TAX_CLASS;
	  $this->output = array();
	}

	function process() {
	  global $order, $ot_subtotal, $currencies;
	  $od_amount = $this->calculate_credit();
	  if ($od_amount != 0) {
		$this->deduction = $od_amount;
		$this->output[] = array('title' => $this->title . ':',
							  'text' => $currencies->format($od_amount),
							  'value' => $od_amount);
		$order->info['total'] = $order->info['total'] + $od_amount;  
	  }
	}
	

  function calculate_credit() {
	global $order, $customer_id, $payment;
	$od_amount=0;
	$table = split("[:,]" , MODULE_FIXED_PAYMENT_CHG_TYPE);
	for ($i = 0; $i < count($table); $i+=3) {
	  if ($payment == $table[$i]) {

$od_min_fee=$table[$i+1];
$od_fee = $table[$i+2] * $order->info['subtotal'];

if ($od_min_fee < $od_fee) {
$od_am = $od_fee;
} 
else {
$od_am = $od_min_fee;
}

		if (MODULE_FIXED_PAYMENT_CHG_TAX_CLASS > 0) {
		  // If tax class is defined, get the tax rate according to delivery country and zone
		  // $tod_rate = tep_get_tax_rate(MODULE_FIXED_PAYMENT_CHG_TAX_CLASS); // Amended for tax calculation fix
		  $tod_rate = tep_get_tax_rate(MODULE_FIXED_PAYMENT_CHG_TAX_CLASS,$order->delivery['country']['id'], $order->delivery['zone_id']); // Added for tax fix
		  $tax_description = tep_get_tax_description(MODULE_FIXED_PAYMENT_CHG_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
		if ($od_min_fee < $od_fee) {
			if (DISPLAY_PRICE_WITH_TAX=="true") { 
				$tod_amount =  tep_calculate_tax($od_am / (1 + ($tod_rate / 100)), $tod_rate);
				  $order->info['tax_groups']["$tax_description"] += tep_calculate_tax($od_am / (1 + ($tod_rate / 100)), $tod_rate);
			} else {
				  $tod_amount =  tep_calculate_tax($od_am, $tod_rate);
				  $order->info['tax_groups']["$tax_description"] += tep_calculate_tax($od_am, $tod_rate);
				  $order->info['total'] += $tod_amount;
			}
	   		  $od_amount = $od_am;
		} else {
   			$tod_amount =  tep_calculate_tax($od_am, $tod_rate);
	   		  $order->info['tax_groups']["$tax_description"] += tep_calculate_tax($od_am, $tod_rate);
			if (DISPLAY_PRICE_WITH_TAX=="true") { 
				  $od_amount = $od_am + $tod_amount;
		  } else {
			$od_amount = $od_am;
		  }
		}
	  }
	  return $od_amount;
	}

  function get_payment_cost($pay_type) {
	global $order;
	
	  $od_amount=0;
	  $table = split("[:,]" , MODULE_FIXED_PAYMENT_CHG_TYPE);
	  for ($i = 0; $i < count($table); $i+=3) {
		if ($pay_type == $table[$i]) {
			$od_min_fee=$table[$i+1];
			$od_fee = $table[$i+2] * $order->info['subtotal'];

			if ($od_min_fee < $od_fee) {
				$od_am = $od_fee;
			} else {
				$od_am = $od_min_fee;
			}
			  if (MODULE_FIXED_PAYMENT_CHG_TAX_CLASS > 0) {
			$tod_rate = tep_get_tax_rate(MODULE_FIXED_PAYMENT_CHG_TAX_CLASS,$order->delivery['country']['id'], $order->delivery['zone_id']);
			if ($od_min_fee < $od_fee) {
				if (DISPLAY_PRICE_WITH_TAX=="true") {
					$tod_amount =  tep_calculate_tax($od_am / (1 + ($tod_rate / 100)), $tod_rate);
				} else {
					$tod_amount =  tep_calculate_tax($od_am, $tod_rate);
				}
					$od_amount = $od_am;
			} else {
					$tod_amount =  tep_calculate_tax($od_am, $tod_rate);
				if (DISPLAY_PRICE_WITH_TAX=="true") {
					$od_amount = $od_am + $tod_amount;
		  } else {
			$od_amount = $od_am;
		  }
		}
	  }
	  return $od_amount;
	}

	
	function check() {
	  if (!isset($this->check)) {
		$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_FIXED_PAYMENT_CHG_STATUS'");
		$this->check = tep_db_num_rows($check_query);
	  }

	  return $this->check;
	}

	function keys() {
	  return array('MODULE_FIXED_PAYMENT_CHG_STATUS', 'MODULE_FIXED_PAYMENT_CHG_SORT_ORDER', 'MODULE_FIXED_PAYMENT_CHG_TYPE', 'MODULE_FIXED_PAYMENT_CHG_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 ('Display fee', 'MODULE_FIXED_PAYMENT_CHG_STATUS', 'true', 'Display fee related to the payment type', '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_FIXED_PAYMENT_CHG_SORT_ORDER', '3', 'Display sort order.', '6', '2', now())");
	  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Fee for payment type', 'MODULE_FIXED_PAYMENT_CHG_TYPE', 'cod:2.70:0.035,paypal_ipn:0:0.03', 'Payment methods with minimal fee (any) and normal fee (0 to 1, 1 is 100%) all splitted by colons, enter like this: [cod:xx:0.yy,paypal_ipn:xx:0.yy] ', '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', 'MODULE_FIXED_PAYMENT_CHG_TAX_CLASS', '0', 'Use the following tax class:', '6', '6', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
	}
/*	Si vous désirez installer ce module en francais, remplacer la function "install" par celle-ci:
	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 ('Afficher les frais', 'MODULE_FIXED_PAYMENT_CHG_STATUS', 'true', 'Afficher les frais en fonction du type de mode de paiement', '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 ('Ordre', 'MODULE_FIXED_PAYMENT_CHG_SORT_ORDER', '3', 'Ordre d\'affichage.', '6', '2', now())");
	  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Frais du type de paiement', 'MODULE_FIXED_PAYMENT_CHG_TYPE', 'contremb:9:0.05', 'Frais &agrave; ajouter au paiement, de la forme [cod:xx:0.yy,moneyorder:xx:0.yy] ', '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 ('Taxes', 'MODULE_FIXED_PAYMENT_CHG_TAX_CLASS', '0', 'Utiliser la classe de taxe suivante.', '6', '6', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
	}	
*/
	function remove() {
	  $keys = '';
	  $keys_array = $this->keys();
	  for ($i=0; $i<sizeof($keys_array); $i++) {
		$keys .= "'" . $keys_array[$i] . "',";
	  }
	  $keys = substr($keys, 0, -1);

	  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
	}
  }
?>


#23   solosc

solosc
  • Members
  • 10 posts
  • Real Name:Sebastiaan

Posted 22 June 2009 - 19:18

Hope you can help ánd it's easy to resolve...

Edited by solosc, 22 June 2009 - 19:19.


#24   xenonex

xenonex
  • Members
  • 1 posts
  • Real Name:Francis

Posted 01 July 2009 - 18:42

Thanks for this work Jan, its just what I was looking for. One question though, why didn't you include the revised login system? I would like to add that as well. Can you offer any advice on including that? Thanks!

#25   Jan Zonjee

Jan Zonjee

    Governor of Peace

  • Core Team
  • 7,093 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 01 July 2009 - 19:14

Why didn't you include the revised login system?

A. It is not described in the updates to begin with. I also saw you need to make quite a few changes in quite a number of files to add the new login mechanism (different front page too).
B. Sifting through the updates, putting them together file by file and in a sequence that would get a shop up and running again as soon as possible, describing the updates, testing them, making the diffs etc. took so incredibly much time that I didn't feel like adding that too :)

#26   seyoung

seyoung
  • Members
  • 3 posts
  • Real Name:Steve Young

Posted 04 July 2009 - 17:44

Sorry if this is simple, we just do not want to make errors on this upgrade.

I have gone through the document "Upgrading osC from 2.2 MS2 to 2.2 RC2a" readme and upgrade files.

We have installed diffMerge and are ready to make the changes as noted.

However we have never installed any contributions that I know of. So would we just replace the MS2 files with the RC2a files?

Or do we edit all our existing files?

If so does the data base need any changes to work with 2.2 RC2a, we have made no changes to that other than adding products in the admin area of osCommerse?

We are running PHP 4.4.4 so do not have a problem with MS2, but would like to upgrade before we add a contribution (we were going to add coupons) When this upgrade is done we would upgrade to PHP 5.2.6

Thank you in advance for your valuable time.

Steve

#27   Jan Zonjee

Jan Zonjee

    Governor of Peace

  • Core Team
  • 7,093 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 04 July 2009 - 19:41

However we have never installed any contributions that I know of. So would we just replace the MS2 files with the RC2a files?

If after comparing each of your own files with the ones in the directory/folder catalog_22_ms2 confirms nothing was changed it would be best to just replace the files with those in catalog_22rc2a (minimum amount of work, no change of errors).

If so does the data base need any changes to work with 2.2 RC2a, we have made no changes to that other than adding products in the admin area of osCommerse?

After the list of 87 files there are changes to the database mentioned under the heading SQL changes from RC1 and RC2a combined. The biggest chunk of it is adding indexes to a number of tables, enlarging a couple of database fields but there are a few that have to do with changes for order statuses and for external payment providers like Paypal. If you use the new files you will also need to add the database changes otherwise you get errors (the other way around you would get errors too).

We are running PHP 4.4.4 so do not have a problem with MS2, but would like to upgrade before we add a contribution (we were going to add coupons) When this upgrade is done we would upgrade to PHP 5.2.6

A lot of small improvements and security fixes went into the updates also. Updating would be wise anyway (and vital if you went to MySQL5 or your hosting environments doesn't allow "register_globals = on" anymore.

#28   Jan Zonjee

Jan Zonjee

    Governor of Peace

  • Core Team
  • 7,093 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 04 July 2009 - 19:50

I noticed that the ot_fixed_payment_chg.php file I have been using is different, so just to be sure I downloaded the contrib again and first followed the instructions. Installed ok, but not displayed on checkout_confirmation.

Once I complete your steps (especially the proposed change in ot_fixed_payment_chg.php) I get error in admin:
Parse error: syntax error, unexpected $end in /home/id03648/domains/wuite.net/public_html/includes/modules/order_total/ot_fixed_payment_chg.php on line 164
in the order total overview page.

You probably fixed this by now but I notice both the function calculate credit and get_payment_cost are missing two closing curly braces ( } ).

#29   seyoung

seyoung
  • Members
  • 3 posts
  • Real Name:Steve Young

Posted 04 July 2009 - 20:35

If after comparing each of your own files with the ones in the directory/folder catalog_22_ms2 confirms nothing was changed it would be best to just replace the files with those in catalog_22rc2a (minimum amount of work, no change of errors).


That is what I thought but I wanted to be sure, I only found one small change so far, and do not know why it is there, I will go through them all and make sure they are the same. and if so upload the rc2a files AFTER... edits to the database.

After the list of 87 files there are changes to the database mentioned under the heading


I am sorry, in the "list_of_files.html" (file) I find no database edits, only php files to edit.
I also found no database edits in the "Upgrade.html" file. /unsure.gif' class='bbc_emoticon' alt=':unsure:' />

I did find the following two database edits noted in the main RC2a zip file, upgrade-22rc1.html (downloaded from the main page)

Database Changes to Perform:
alter table configuration modify configuration_title varchar(255) NOT NULL;
alter table configuration modify configuration_key varchar(255) NOT NULL;

Database Changes to Perform:
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Product Quantities In Shopping Cart', 'MAX_QTY_IN_CART', '99', 'Maximum number of product quantities that can be added to the shopping cart (0 for no limit)', '3', '19', now());


Am I looking in the wrong place for these database changes?
I am not a database expert but can use phpMyAdmin with guidance.

Thank you for your very fast help on this I appreciate it very much.

Steve

#30   Jan Zonjee

Jan Zonjee

    Governor of Peace

  • Core Team
  • 7,093 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 05 July 2009 - 07:37

I also found no database edits in the "Upgrade.html" file.

They are there, right after the big table with the list of files.

I did find the following two database edits noted in the main RC2a zip file, upgrade-22rc1.html (downloaded from the main page)

There are also database edits in RC1. The upgrade.html combines them.

#31   seyoung

seyoung
  • Members
  • 3 posts
  • Real Name:Steve Young

Posted 05 July 2009 - 15:47

I found them under the big bold "SQL changes from RC1 and RC2a combined" title under the table and above the php edits. /blush.gif' class='bbc_emoticon' alt=':blush:' />

I am off to change them, just one more question, if I do the database edits first, will MS2 continue to run, till I upload the RC2a files. Sorry if this brings a laugh, this is not something I work with everyday.

Thanks again for the assistance, I could not have done this without the help.

Steve

#32   Jan Zonjee

Jan Zonjee

    Governor of Peace

  • Core Team
  • 7,093 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 05 July 2009 - 15:58

if I do the database edits first, will MS2 continue to run, till I upload the RC2a files.

Yes, I would think so. Just in case I'm wrong I wouldn't wait too long with updating the files :)

#33   solosc

solosc
  • Members
  • 10 posts
  • Real Name:Sebastiaan

Posted 05 July 2009 - 19:08

You probably fixed this by now but I notice both the function calculate credit and get_payment_cost are missing two closing curly braces ( } ).


Hi Jan,

yes I found the two missing curly braces. I even added the entry to the db (order_total_installed) but still doesn't work.
However, it seems that this version is really different from the file I have in my Live shop. Because in my Live shop the entry only appears if particular payment module is selected (currently the line is displayed on checkout page for every payment method which is wrong) and also I'm able to put a fixed amount instead of a percentage while now I can only enter percentage. The configuration variables in admin are different as well. So for some reason I've got a different ot_fixed_payment_chg.php despite that the file names is called the same (also header).

I think I have to compare the files or find the REAL contrib that covers my module that I have in my Live shop.

Thanks for you help. I'll let you know once I've got it working or if I get stuck there as well.
Will come back to you. Give me a few days.

#34   bmpt

bmpt
  • Members
  • 5 posts
  • Real Name:alex

Posted 06 July 2009 - 17:00

hello, I tried to update from ms2.2 to 2.2rc2a last night.

My catalog has a custom template so when i swapped out the with the new rc2a files, I had layout issues and errors in the template.

I am now reverting to manually adding the rc2a updates.

I have began to edit catalog/index.php

the lines

echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
echo '</form></td>' . "\n";

are completely absent from my template. Am i able to add

echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
echo tep_hide_session_id() . '</form></td>' . "\n";

to the file even though the custom template had left the original lines out

#35   ecartz

ecartz
  • Members
  • 1,964 posts
  • Real Name:Matt
  • Gender:Male

Posted 06 July 2009 - 17:17

Am i able to add

echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
echo tep_hide_session_id() . '</form></td>' . "\n";

to the file even though the custom template had left the original lines out

I would expect that that would break things and would not add pull downs where they aren't already. You absolutely should not add a </form> if it is not there already. You may have to do something similar to compensate. In particular, you should make sure that all forms have the session ID somewhere. If you find a </form>, you may need to add the session ID if is a GET form. In the POST forms, I think that the session ID would already be provided by the action URL.
Always backup before making changes.

#36   solosc

solosc
  • Members
  • 10 posts
  • Real Name:Sebastiaan

Posted 12 July 2009 - 13:25

Hi Jan,

yes I found the two missing curly braces. I even added the entry to the db (order_total_installed) but still doesn't work.
However, it seems that this version is really different from the file I have in my Live shop. Because in my Live shop the entry only appears if particular payment module is selected (currently the line is displayed on checkout page for every payment method which is wrong) and also I'm able to put a fixed amount instead of a percentage while now I can only enter percentage. The configuration variables in admin are different as well. So for some reason I've got a different ot_fixed_payment_chg.php despite that the file names is called the same (also header).

I think I have to compare the files or find the REAL contrib that covers my module that I have in my Live shop.

Thanks for you help. I'll let you know once I've got it working or if I get stuck there as well.
Will come back to you. Give me a few days.


I've tried to compare but it seems the original file of this contrib and the file I've got in my Live shop differs a lot. I have no clue what to change because the two functions you mentioned earlier to modify are different or doesn't exist in my file used in Live shop.
I've checked many other contribs but none of them are suitable or do not work either. Guess I have to stick with the ot_fixed_payment_chg.php file I have in my live shop.
I would therefore very much appreciate if you could have another look at this file (below) and come up with any suggestions. Hope you can simulate this in your test environment to see what code is not good for 2.2 RC2a.

<?php
/*
  $Id: ot_fixed_payment_chg.php,v 1.6 2006/04/12 13:47:12 wilt Exp $

  -----
  Update by Carsten Thinius, thinius@gmx.de
  Description:
  - new configuration field with opportunity to set the fee-description
	in dependence of chosen payment method
	(shown in checkout_confirmation.php and Admin/Orders/Details)
  - bugfix: tax is now calculated & displayed correctly in
			checkout_confirmation.php and Admin/Orders/Details
  -----

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

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/

  class ot_fixed_payment_chg {
	var $title, $output;

	function ot_fixed_payment_chg() {
	  global $payment;

	  $this->code = 'ot_fixed_payment_chg';
	  $this->title = MODULE_FIXED_PAYMENT_CHG_TITLE;
	  $this->description = MODULE_FIXED_PAYMENT_CHG_DESCRIPTION;
	  // bol ct: dynamic title/description of fee
	  if (isset($payment)) {
		$table = split("[:,]" , MODULE_FIXED_PAYMENT_CHG_TYPE_DESCRIPTION);
		for ($i = 0; $i < count($table); $i+=2) {
		  if ($payment == $table[$i]) {
			$this->title = $table[$i+1];
			$this->description = $table[$i+1];
		  }
		}
	  }
	  // eol ct: dynamic title/description of fee
	  $this->enabled = MODULE_FIXED_PAYMENT_CHG_STATUS;
	  $this->sort_order = MODULE_FIXED_PAYMENT_CHG_SORT_ORDER;
	  $this->type = MODULE_FIXED_PAYMENT_CHG_TYPE;
	  $this->tax_class = MODULE_FIXED_PAYMENT_CHG_TAX_CLASS;
	  $this->output = array();
	}

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

	  $od_amount = $this->calculate_charge($this->get_order_total());
	  if ($od_amount != 0) {
		$this->deduction = $od_amount;
		$this->output[] = array('title' => $this->title . ':',
								'text' => $currencies->format($od_amount),
								'value' => $od_amount);
		  $order->info['total'] = $order->info['total'] + $od_amount;
		if ($this->sort_order < $ot_subtotal->sort_order) {
		  $order->info['subtotal'] = $order->info['subtotal'] - $od_amount;
		}
	  }
	}

	function calculate_charge($amount) {
	  global $order, $customer_id, $payment;
	  $od_amount=0;
	  $table = split("[:,]" , MODULE_FIXED_PAYMENT_CHG_TYPE);
	  for ($i = 0; $i < count($table); $i+=3) {
		if ($payment == $table[$i]) {
		  $od_am_fixed=$table[$i+1];
		  $od_am_percentage=$table[$i+2];

		  // use either a fixed amount or percentage of total incl. shipping
		  if (substr($od_am_percentage,0,1) == '%') {
			$od_am_percentage=substr($od_am_percentage, 1);
			$od_am_percentage=round($amount/100*$od_am_percentage,2); // choose the decimal position for rounding
			$table[$i+2]=$od_am_percentage;
		  }

		  if (MODULE_FIXED_PAYMENT_CHG_TAX_CLASS > 0) {
			$tod_rate = tep_get_tax_rate(MODULE_FIXED_PAYMENT_CHG_TAX_CLASS);
			$tod_description = tep_get_tax_description(MODULE_FIXED_PAYMENT_CHG_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
			$tod_amount =  tep_calculate_tax($od_am_fixed + $od_am_percentage, $tod_rate);
			$order->info['tax'] += $tod_amount;
			$order->info['tax_groups'][$tod_description] += tep_calculate_tax($table[$i+1] + $table[$i+2], $tod_rate);
		  }

		  if (DISPLAY_PRICE_WITH_TAX) { 
			$od_amount = $od_am_fixed + $od_am_percentage + $tod_amount;
		  } else {	   
			$od_amount = $od_am_fixed + $od_am_percentage;
			$order->info['total'] += $tod_amount;
		  }
		}
	  }
	  return $od_amount;
	}

	function get_order_total() {
	  global  $order, $cart;
	  $order_total = $order->info['total'];
	  // Check if gift voucher is in cart and adjust total
	  $products = $cart->get_products();
	  for ($i=0; $i<sizeof($products); $i++) {
		$t_prid = tep_get_prid($products[$i]['id']);
		$gv_query = tep_db_query("select products_price, products_tax_class_id, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
		$gv_result = tep_db_fetch_array($gv_query);
		if (ereg('^GIFT', addslashes($gv_result['products_model']))) { 
		  $qty = $cart->get_quantity($t_prid);
		  $products_tax = tep_get_tax_rate($gv_result['products_tax_class_id']);
		  if ($this->include_tax =='false') {
			$gv_amount = $gv_result['products_price'] * $qty;
		  } else {
			$gv_amount = ($gv_result['products_price'] + tep_calculate_tax($gv_result['products_price'],$products_tax)) * $qty;
		  }
		  $order_total=$order_total - $gv_amount;
		}
	  }
	  if ($this->include_tax == 'false') $order_total=$order_total-$order->info['tax'];
	  if ($this->include_shipping == 'false') $order_total=$order_total-$order->info['shipping_cost'];
	  return $order_total;
	}

	function check() {
	  if (!isset($this->check)) {
		$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_FIXED_PAYMENT_CHG_STATUS'");
		$this->check = tep_db_num_rows($check_query);
	  }

	  return $this->check;
	}

	function keys() {
	  return array('MODULE_FIXED_PAYMENT_CHG_STATUS', 'MODULE_FIXED_PAYMENT_CHG_SORT_ORDER', 'MODULE_FIXED_PAYMENT_CHG_TYPE', 'MODULE_FIXED_PAYMENT_CHG_TYPE_DESCRIPTION', 'MODULE_FIXED_PAYMENT_CHG_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 ('Toon betaalmethode toeslag', 'MODULE_FIXED_PAYMENT_CHG_STATUS', 'true', 'Wilt u de betaalmethode toeslag laten zien?', '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 ('Sorteervolgorde', 'MODULE_FIXED_PAYMENT_CHG_SORT_ORDER', '10', 'Sorteervolgorde', '6', '2', now())");
	  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Kortingspercentage', 'MODULE_FIXED_PAYMENT_CHG_AMOUNT', '2', 'Kortingsbedrag', '6', '7', now())");
	  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Betaalmethode', 'MODULE_FIXED_PAYMENT_CHG_TYPE', 'moneyorder:5:%0,cod:50:%10', 'Betaalmethoden waar u een toeslag over wilt heffen', '6', '2', now())");
	  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Betaalmethode toeslag beschrijving', 'MODULE_FIXED_PAYMENT_CHG_TYPE_DESCRIPTION', 'moneyorder:Overboeking Transactiekosten,cod:Rembours Transactiekosten', 'Beschrijving voor elke betalingsmethode', '6', '3', 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 ('Belasting', 'MODULE_FIXED_PAYMENT_CHG_TAX_CLASS', '0', 'Hef de volgende belasting klasse over de betaalmethode toeslag', '6', '6', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
	}

	function remove() {
	  $keys = '';
	  $keys_array = $this->keys();
	  for ($i=0; $i<sizeof($keys_array); $i++) {
		$keys .= "'" . $keys_array[$i] . "',";
	  }
	  $keys = substr($keys, 0, -1);

	  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
	}
  }
?>
Just to clarify that this file works without problems in oscommerce 2.2 and allows me based on payment method to add fixed fee (and/or % which I'm not using) to the order total page. In RC2a the fee is doubled (refer to my original posting).
many thanks in advance!

#37   bmpt

bmpt
  • Members
  • 5 posts
  • Real Name:alex

Posted 21 July 2009 - 04:52

I would expect that that would break things and would not add pull downs where they aren't already. You absolutely should not add a </form> if it is not there already. You may have to do something similar to compensate. In particular, you should make sure that all forms have the session ID somewhere. If you find a </form>, you may need to add the session ID if is a GET form. In the POST forms, I think that the session ID would already be provided by the action URL.

Ok, so after all GET forms I need to add the session ID. Im assuming i add tep_hide_session_id() . just after the echo tag and just before the </form>

any help is much appreciated...

#38   solosc

solosc
  • Members
  • 10 posts
  • Real Name:Sebastiaan

Posted 26 July 2009 - 13:22

Just to let you know that I managed to fix the issue.

I went through the process of comparing my RC2a files (checkout_payment, confirmation, process and success) with the official RC2a download package.
I could not really find big differences except for a custom payment module that I have implemented some years ago. I got the feeling that this must cause the difference between working well in other environments except mine. So, I deleted everything and put back original code and now it works !!!!

I have also found a more recent contrib for that payment module so now everything works!

So nothing wrong with the upgrade or ot_fixed_payment_chg.php, it was just a custom payment module which got outdated with this RC2a release.

/rolleyes.gif' class='bbc_emoticon' alt=':rolleyes:' />

#39   edukes

edukes
  • Members
  • 145 posts
  • Real Name:Eddie

Posted 03 August 2009 - 22:37

Just got finished editing the files to upgrade and ran the sql changes.

I get the following error:

Error

SQL query:

ALTER TABLE banners ADD INDEX idx_banners_group( banners_group ) ;

MySQL said: Documentation
#1061 - Duplicate key name 'idx_banners_group'

In fact, after commenting the line out, it rejects the next one, etc. The following lines get the same error:

alter table banners add index idx_banners_group (banners_group);
alter table banners_history add index idx_banners_history_banners_id (banners_id);
alter table currencies add index idx_currencies_code (code);
alter table customers_basket add index idx_customers_basket_customers_id (customers_id);
alter table customers_basket_attributes add index idx_customers_basket_att_customers_id (customers_id);

I quit trying after commenting these lines out with no success.

I am running 2.2ms2-060817, mysql 4.1, and php 4.3.11 on godaddy servers.

Any help would be appreciated.

#40   mpwtreasure

mpwtreasure
  • Members
  • 5 posts
  • Real Name:Catherine Funderburg

Posted 11 August 2009 - 15:16

Thank you for your big and good work.

I have a question: I have a 2.2 ms version installed but updated to RC1.

This contribution you made can't be used by me, isn't it?

Its posible to make a contribution to update from "2.2 upgrade RC1" to "RC2"?

Waiting your answer.

Kind regards!!!


Catherine Funderburg