Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Upgrading osC from 2.2 MS2 to 2.2 RC2a


Recommended Posts

This is the support thread for the "Upgrading osC from 2.2 Milestone 2 to 2.2 RC2a" contribution (addon #6654).

 

This contribution documents and describes the changes to update a osCommerce 2.2 milestone 2 shop to the latest version (release candidate 2a).

 

This is useful for example in case your hosting upgraded MySQL to version 5, PHP to version 5, decided to set register globals to off or you want to implement the latest bugfixes and security fixes.

Edited by Jan Zonjee
Link to comment
Share on other sites

This is the support thread for the "Upgrading osC from 2.2 Milestone 2 to 2.2 RC2a" contribution (addon #6654).

 

This contribution documents and describes the changes to update a osCommerce 2.2 milestone 2 shop to the latest version (release candidate 2a).

 

This is useful for example in case your hosting upgraded MySQL to version 5, PHP to version 5, decided to set register globals to off or you want to implement the latest bugfixes and security fixes.

 

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!!!

Link to comment
Share on other sites

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"?

In the listing of files at the top of upgrade.html the last column on the right shows the issues and files which have been updated in RC2. If you use that list and check the changes for each file you will also see that with each code change for a file it mentions for which issue that is done. If it doesn't say so, it is the issue that was last mentioned.

So you could use this for upgrading from RC1 to RC2 also, but it takes a bit more effort.

 

Using the list of files that were updated in RC2 and a compare and merge program comparing/merging your files with those of RC2 should get you there too.

 

You would have to check the upgrade document for RC2 in the folder extras to see what sql changes were done solely in RC2.

Link to comment
Share on other sites

In the listing of files at the top of upgrade.html the last column on the right shows the issues and files which have been updated in RC2. If you use that list and check the changes for each file you will also see that with each code change for a file it mentions for which issue that is done. If it doesn't say so, it is the issue that was last mentioned.

So you could use this for upgrading from RC1 to RC2 also, but it takes a bit more effort.

 

Using the list of files that were updated in RC2 and a compare and merge program comparing/merging your files with those of RC2 should get you there too.

 

You would have to check the upgrade document for RC2 in the folder extras to see what sql changes were done solely in RC2.

 

Thank you Jan for your answer.

 

Do you think, this will make faster the sql work? I've change my php4 server to php5 and now the search work is so slow than php4 server.

 

RC2 changes can make this faster?

 

Thank you again for your big work.

 

Kind regards.

 

Cesar

Link to comment
Share on other sites

Do you think, this will make faster the sql work? I've change my php4 server to php5 and now the search work is so slow than php4 server.

 

RC2 changes can make this faster?

Some queries should be faster. Especially the ones that involve the table specials should perform better.

Link to comment
Share on other sites

Hi

 

I am in the process of updating my osCommerce 2.2 MS2 to rc2a and I am manually editing each file because I have quite a few contributions in my store.

 

I have run into a problem as shown below.

 

Parse error: parse error in /catalog/includes/functions/compatibility.php on line 179

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /catalog/includes/functions/compatibility.php:179) in /catalog/includes/functions/sessions.php on line 99

 

Can anyone offer any advice on how to overcome this.

 

Thanks in advance

Edited by Viper0409
Link to comment
Share on other sites

Can anyone offer any advice on how to overcome this.

Fix the parse error on line 179 in the file /catalog/includes/functions/compatibility.php or better yet exchange that file with the one in the package. I can't think of a contribution that would want to change something in there but I might be wrong...

Edited by Jan Zonjee
Link to comment
Share on other sites

ok I just compared the two files, one from the package and my local file, and this is the only difference.

 

if (!is_array($ar)) return false;

 

and

 

if (is_array($ar[$key])) {

do_magic_quotes_gpc($ar[$key]);

 

The first quote is the package file and the second is my file. Should I make it same as the package file or would there be a reason for the difference?

 

Thanks

Edited by Viper0409
Link to comment
Share on other sites

Ok I went ahead and made the above change to the compatibility.php file and it has cleared the problem. It remains to be seen if something else is broken, but I will keep my fingers crossed.

 

BTW, thanks for this awesome contribution. It makes life so much easier to be able to follow step by step each step of the upgrade.

Link to comment
Share on other sites

The first quote is the package file and the second is my file. Should I make it same as the package file or would there be a reason for the difference?

Looks like you misinterpreted the instructions slightly. The line you added the do_magic_quotes_gpc after is on it's own. For comparison this is the old function:

  function do_magic_quotes_gpc(&$ar) {
if (!is_array($ar)) return false;

while (list($key, $value) = each($ar)) {
  if (is_array($value)) {
	do_magic_quotes_gpc($value);
  } else {
	$ar[$key] = addslashes($value);
  }
}
 }

This is the new function:

  function do_magic_quotes_gpc(&$ar) {
if (!is_array($ar)) return false;

reset($ar);
while (list($key, $value) = each($ar)) {
  if (is_array($ar[$key])) {
	do_magic_quotes_gpc($ar[$key]);
  } else {
	$ar[$key] = addslashes($value);
  }
}
reset($ar);
 }

Link to comment
Share on other sites

  • 1 month later...
Does this only work with unmodded sites? I have a custom template with contributions installed. Will that fact make it difficult to impossable to make the changes myself manually?

A lot of the code changes are in files a template wouldn't need to touch. But undoubtedly there will be files that have been changed by contributions that will need some consideration before adding the changes needed for the upgrading.

No general answer can be given of course.

Link to comment
Share on other sites

A lot of the code changes are in files a template wouldn't need to touch. But undoubtedly there will be files that have been changed by contributions that will need some consideration before adding the changes needed for the upgrading.

No general answer can be given of course.

 

Before I upgrade from rc1 to rc2, I'd like to know if any functionality will be removed by upgrading? I don't really want to loose anything that I have now with my rc1 setup! I don't mean functionality that I personally have added, I rather mean from stock rc1 to stock rc2, so to speak.

 

As I interpret the upgrade document, each upgrade change is independent of the other. If so, I should be OK by leaving out a few changes!? I'm asking this because I have quite a few contributions installed that might cause difficulties in doing some changes (since I'm not an experienced coder).

 

Also, I'm curious about why $HTTP_POST_VARS and $HTTP_GET_VARS has been used in upgrade changes as opposed to the global $_POST and $_GET?

Link to comment
Share on other sites

Before I upgrade from rc1 to rc2, I'd like to know if any functionality will be removed by upgrading? I don't really want to loose anything that I have now with my rc1 setup! I don't mean functionality that I personally have added, I rather mean from stock rc1 to stock rc2, so to speak.

I don't remember functionality being removed but with contributions you have to be aware of the changing of tep_add_tax to using a new function in the class currencies.

As I interpret the upgrade document, each upgrade change is independent of the other. If so, I should be OK by leaving out a few changes!? I'm asking this because I have quite a few contributions installed that might cause difficulties in doing some changes (since I'm not an experienced coder).

I wouldn't know. I would try to add everything personally.

Also, I'm curious about why $HTTP_POST_VARS and $HTTP_GET_VARS has been used in upgrade changes as opposed to the global $_POST and $_GET?

If you really wanted to change all of them you would have to change almost every file in osC. For the new code I would have preferred to use the $_POST and $_GET but I think the official party line is that it would not be PHP3 compatible. In one of the updates Harald even rolled back using $_POST and $_GET to $HTTP_POST_VARS and $HTTP_GET_VARS because of that. I think it was somewhere in the admin for whos_online or something like that (left that out BTW).

 

Never seen someone mentioning an error using that so that should tell you something about how many stores were still using PHP3 when MS2.2 started...

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

I have managed to follow your instructions and completed all the steps. Thank you very much for putting this together!

 

Everything works, except for one thing.

On the checkout_confirmation page the amount for a fixed payment charge (module: http://www.oscommerce.com/community/contributions,4125) is doubled.

This is an Order Total module contrib.

 

If I choose any shipping or payment combination it does work as expected. However, as soon as I choose the payment option which triggers this order total module it duplicates the amount.

 

Example:

shopping cart (free payment method chosen)

item 1: 50.00

item 2: 50.00

subtotal: 100.00

shipping: 5.00

total: 105.00

 

Now I choose a payment method that adds a fee of 7.50 (setup in admin as order total):

shopping cart

item 1: 50.00

item 2: 50.00

subtotal: 100.00

shipping: 5.00

payment fee: 7.50

total: 120.00

 

You see, although the payment fee shows as 7.50 (as maintained in admin, order total module) the total is increased by twice this fee (7.50x2=15.00).

 

This only happens in my new upgraded store after I completed all the steps.

I'm just wondering if you or any one has any idea?

Is it something that is changed in checkout_confirmation.php, order.php or shoppingcart.php ?

Or do I need to change coding of this order total module contrib (not desired) and besides it only occurs now after I upgraded.

 

I do hope someone can just tell me where the cause for this issue occurs, so that I can reverse that part (if possible) or check whether I indeed followed exactly the instructions.

 

Thanks!

Link to comment
Share on other sites

This only happens in my new upgraded store after I completed all the steps.

I'm just wondering if you or any one has any idea?

In the support thread it is mentioned it is not working with rc2. To check if it was something simple I even installed it and I can tell you I cannot even get it working. For some reason I can see the fee announced in checkout_payment.php but then it disappears again and it never gets added to the total in the next page.

 

Must be something with the global and using the wrong ones in the contribution or something like that. No clue how to fix this.

Link to comment
Share on other sites

In the support thread it is mentioned it is not working with rc2. To check if it was something simple I even installed it and I can tell you I cannot even get it working. For some reason I can see the fee announced in checkout_payment.php but then it disappears again and it never gets added to the total in the next page.

 

Must be something with the global and using the wrong ones in the contribution or something like that. No clue how to fix this.

 

thanks anyway. I noticed the comments in that support thread and it's suggested to use an alternative contrib. I'll try this.

At least the issue can be marked as related to the contrib and not to the upgrade I've done.

Link to comment
Share on other sites

I tried several other contribs.

Some of them didn't allow to enter a fixed amount/fee only (just a percentage).

 

The only other contrib that seems to allow this is: http://addons.oscommerce.com/info/801

However, after having it installed I have exactly the same problem.

 

Seems to be R2a issue. Just suprised that this hasn't been fixed in meantime.

It's quite annoying because I can't continue the upgrade if I can't use an order total module that allows to add a fixed fee.

 

I'll try to reverse the R2a upgrade steps of the checkout_confirmation page only and leave others as they are.

Alternatively someone could check the code. Unfortunately I'm not a programmer. Any help is appreciated of course!

 

Should this issue be logged as a bug of R2a?

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

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 [email protected] to get it working with tax class
 * Modified by Giovanni Putignano ([email protected]), 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 à 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 . ")");
}
 }
?>

Link to comment
Share on other sites

  • 2 weeks later...

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!

Link to comment
Share on other sites

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 :)

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...