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

#81   Remco Leuven

Remco Leuven
  • Members
  • 11 posts
  • Real Name:Remco Leuven

Posted 01 June 2010 - 16:14

Hello, first of all; thanks for this great way to update the shop without having to install a new shop without any contributions.

I've changed all the files and the shop is working like a charm but there's one problem. When customers are paying via iDeal, they won't receive the orderconfirmation. Neither do the people who are in the 'send extra order emails to' part in the admin area.

The email is send from the file catalog/checkout_process.php, I've tried to find a solution myself. I thought I solved it because one line of code was referring to admin/ideal_mail.php whilst I just renamed the admin folder to something else. But it's still not working.

Please note, emails are being sent just fine when the customer pays via one of the other methods (Paypal or prepaid). It's just the iDeal part.

I used the idealm contribution from the addons-site, no problems with it so far. I think it must be with some lines in the checkout_process.php file that need to be changed to be compatible with the rc2a upgrade. Here are some lines from the checkout_Process.php file that handle the email for iDeal. I really hope you can help me.

Around line 89
// IDEAL AANPASSING
$do_email = true;
if (is_object($$payment)) {
$payment_class = $$payment;
if ($payment_class->code == 'idealm') {
if ((!tep_session_is_registered('trans')) || ($trans != 'success'))
$do_email = false;
}
}

if ((tep_session_is_registered('paymentid')) && ($payment_class->code != 'idealm')) {
tep_db_query("UPDATE ".TABLE_IDEAL_PAYMENTS." SET payment_status='".MODULE_PAYMENT_IDEALM_ORDER_CANCELLED_STATUS_ID."', date_last_check=now() WHERE payment_id='" . $paymentid."'");
tep_session_unregister('paymentid');
tep_session_unregister('trans');
tep_session_unregister('coupon_code_code');
tep_session_unregister('coupon_code_value');
}

if (!tep_session_is_registered('paymentid')) { 
// EINDE IDEAL AANPASSING

Please note that above this piece of code, I've added a new line as was mentioned in the upgrade package, this is the line:
// load the before_process function from the payment modules
  $payment_modules->before_process();

More iDeal related lines:

Around line 175:
// IDEAL AANPASSING
$customer_notification = '0';
if ($payment_class->code == 'idealm') {
if ($do_email)
$customer_notification = '1'; 
} else {
$customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
}
// EINDE IDEAL AANPASSING

Around line 333:
// IDEAL AANPASSING
}
if (($do_email) && ($payment_class->code != 'idealm')) {
// EINDE IDEAAL AANPASSING

Around line 435:
// IDEAL AANPASSING
} elseif ($do_email) {
$orderid = tep_db_query("SELECT order_id FROM " . TABLE_IDEAL_PAYMENTS . " WHERE payment_id='" . $paymentid . "'"); 
$orderid = tep_db_fetch_array($orderid);
$order = new order($orderid['order_id']);
$insert_id = $orderid['order_id'];
$customer_id = $order->customer['id'];
require_once('admin/idealm_email.php');
tep_session_unregister('paymentid');
tep_session_unregister('trans');
tep_session_unregister('coupon_code_code');
tep_session_unregister('coupon_code_value');
}

if ((!$do_email) && ($trans != 'pending')) {
$payment_modules->after_process();
}

// EINDE IDEAL AANPASSING

Around line 472 (I think this is from the first ideal addon I tried, didn't want to remove it because I have (had) no problems with that piece there so far.
/* IDEAAL/IDEAL AANPASSING */
if ((($payment_class->code == 'moneyorder') && (MODULE_PAYMENT_IDEAAL_STATUS != 'True'))
&& (MODULE_PAYMENT_MONEYORDER_INTERNETBANKING == 'True')) {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS_IDEAAL . '?amount=' . $order_totals[$i-1]['value'] . '&ref=' . $insert_id, '', 'SSL'));
} elseif ((($payment_class->code == 'idealm')) && (($trans == 'pending') || ($trans == 'success'))) {
tep_session_unregister('paymentid');
tep_session_unregister('trans');
tep_session_unregister('coupon_code_code');
tep_session_unregister('coupon_code_value');
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));
} else {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));
}
/* EINDE IDEAAL/IDEAL AANPASSING */

I've placed the full checkout_process.php in this spoiler below, maybe that will come in handy?

Spoiler

Edited by Jan Zonjee, 06 June 2010 - 20:48.


#82   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 01 June 2010 - 21:18

I've changed all the files and the shop is working like a charm but there's one problem. When customers are paying via iDeal, they won't receive the orderconfirmation. Neither do the people who are in the 'send extra order emails to' part in the admin area.

The email is send from the file catalog/checkout_process.php, I've tried to find a solution myself. I thought I solved it because one line of code was referring to admin/ideal_mail.php whilst I just renamed the admin folder to something else. But it's still not working.

Please note, emails are being sent just fine when the customer pays via one of the other methods (Paypal or prepaid). It's just the iDeal part.

I used the idealm contribution from the addons-site, no problems with it so far. I think it must be with some lines in the checkout_process.php file that need to be changed to be compatible with the rc2a upgrade.


Judging from your code the iDEAL contribution seems to be 3759. This includes a file located in the admin in checkout_process.php. Personally I would assume you can't do that when that directory is protected with an .htaccess file. So my first suggestion would be to move that file to the includes directory and see if that works better or different.
Second thing that this is a new file that is included and since register_globals might be set to off now that file won't work because it doesn't declare $insert_id a global in that file, neither $customer_id and probably you would need to declare $order a global in there too.

$comments is probably not working either because it is $order->info['comments'] that is needed (see the checkout_process.php).

Adding the idealm_email.php to the includes folder seems like a security risk too. When "calling" that file directly in your browser I would assume it firing off those emails too.

I would assume more Dutch people would have had this problem and the contribution having been updated. Maybe that is why some people don't like RC2a in the Dutch forums? :)

#83   Remco Leuven

Remco Leuven
  • Members
  • 11 posts
  • Real Name:Remco Leuven

Posted 02 June 2010 - 07:26

Judging from your code the iDEAL contribution seems to be 3759. This includes a file located in the admin in checkout_process.php.

That's correct.

Personally I would assume you can't do that when that directory is protected with an .htaccess file. So my first suggestion would be to move that file to the includes directory and see if that works better or different.

Could this explain the fact that it is working fine when I make an iDeal testorder myself? Because I'm then also logged in in the admin area?

Second thing that this is a new file that is included and since register_globals might be set to off now that file won't work because it doesn't declare $insert_id a global in that file, neither $customer_id and probably you would need to declare $order a global in there too.

According to the Server Info in the admin area, register_globals is set to on. But I do want to mention that although I've upgraded to RC2a my host is still running PHP Version 4.4.9-0.dotdeb.1 , would setting it to PHP5 solve the issue?

$comments is probably not working either because it is $order->info['comments'] that is needed (see the checkout_process.php).

Well, when the emails were still send, comments were not included in the email, same for the customer name. The mail started with "Beste ," instead of "Beste Voornaam Achternaam,"

Thanks for your information Jan. I hope we can find a solution for this.

#84   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 02 June 2010 - 11:47

Could this explain the fact that it is working fine when I make an iDeal testorder myself? Because I'm then also logged in in the admin area?

Reasonable assumption.

According to the Server Info in the admin area, register_globals is set to on. But I do want to mention that although I've upgraded to RC2a my host is still running PHP Version 4.4.9-0.dotdeb.1 , would setting it to PHP5 solve the issue?

No, PHP5 is probably even stricter.

Well, when the emails were still send, comments were not included in the email, same for the customer name. The mail started with "Beste ," instead of "Beste Voornaam Achternaam,"

Likely caused by not declaring a number of things global in that file....

Personally, I would rather wrap that code into a function with variables from checkout_process.php. Then it would be much harder to do anything with that file by (would-be) hackers when you put it in the catalog/includes folder.

#85   Remco Leuven

Remco Leuven
  • Members
  • 11 posts
  • Real Name:Remco Leuven

Posted 03 June 2010 - 10:35

can I replace this line from checkout_process.php:
require_once('office/idealm_email.php');
with the actual contents from the idealm_php file?

Edited by Remco Leuven, 03 June 2010 - 10:37.


#86   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 03 June 2010 - 11:04

can I replace this line from checkout_process.php:

require_once('office/idealm_email.php');
with the actual contents from the idealm_php file?

Yes, I think you can do that. Can't think of why not although my first inclination was to say no.

#87   Remco Leuven

Remco Leuven
  • Members
  • 11 posts
  • Real Name:Remco Leuven

Posted 06 June 2010 - 13:44

I've tried two things:

1) I uploaded the admin/idealm_email.php file to the catalog folder and in the checkout_process.php file I changed:
require_once('admin/idealm_email.php');
into
require_once('idealm_email.php');

2) I changed in the checkout_process.php file:
require_once('admin/idealm_email.php');
into
// require_once('admin/idealm_email.php');

and then I placed all code from admin/idealm_email.php directly under it.

Both fixes did not work, still no email sent.

But... I hope I can explain this correctly;

I logged in with my emailaddress and password. Then I placed a product into my basked. I paid the order using iDeal. > No email was sent.
And then, 15 minutes later when I was still logged in, I placed another order, paid via iDeal and when I clicked to the final step I got an iDeal order that some variables were missing. But strangely enough an email was sent succesully after placing the 2nd order, but the email was from the first order, according to the ordernumber and product I ordered.

Maybe it has something to do with the session? How could I fix this then?

#88   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 06 June 2010 - 21:02

I've tried two things:

1) I uploaded the admin/idealm_email.php file to the catalog folder and in the checkout_process.php file I changed:

require_once('admin/idealm_email.php');
into
require_once('idealm_email.php');

2) I changed in the checkout_process.php file:
require_once('admin/idealm_email.php');
into
// require_once('admin/idealm_email.php');

and then I placed all code from admin/idealm_email.php directly under it.

Both fixes did not work, still no email sent.

But... I hope I can explain this correctly;

I logged in with my emailaddress and password. Then I placed a product into my basked. I paid the order using iDeal. > No email was sent.
And then, 15 minutes later when I was still logged in, I placed another order, paid via iDeal and when I clicked to the final step I got an iDeal order that some variables were missing. But strangely enough an email was sent succesully after placing the 2nd order, but the email was from the first order, according to the ordernumber and product I ordered.

Maybe it has something to do with the session? How could I fix this then?


osC cannot hold an email for 15 minutes so this must have been underway.

Actually, I cannot see much difference between the idealm_email.php and the code that checkout_process.php is using. So why the distinction between mail for when the payment class is not idealm and when it is?

I personally would try to change the code (on line 336) :
if (($do_email) && ($payment_class->code != 'idealm')) {
to:
if ($do_email) {
and comment out the lines from and including (from line 437-448)
} elseif ($do_email) {
and see how that works.

#89   Remco Leuven

Remco Leuven
  • Members
  • 11 posts
  • Real Name:Remco Leuven

Posted 07 June 2010 - 13:41

Thanks for all your help. The above fix gives an PHP error (Unexpected $end on line 495) that line is empty though. Maybe I deleted too much lines? I don't have a good editor like Notepad++ here so I had to count lines myself :-)

Edited by Remco Leuven, 07 June 2010 - 13:42.


#90   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 07 June 2010 - 16:14

I don't have a good editor like Notepad++ here so I had to count lines myself :-)

Which is GPL software and free (gratis)... so why don't you have that?

#91   Remco Leuven

Remco Leuven
  • Members
  • 11 posts
  • Real Name:Remco Leuven

Posted 08 June 2010 - 06:57

Ahm, forgot to note that. I am working from 8:30 untill 5.

I do have access to my website (FTP and admin panel) here ar work but I don't have the rights to install software.So I just downloaded the file, looked for the code and deleted the lines.

This weekend I will try it at home again.

Any idea what the 'unexected $end' means?

#92   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 08 June 2010 - 20:39

I do have access to my website (FTP and admin panel) here ar work but I don't have the rights to install software.So I just downloaded the file, looked for the code and deleted the lines.

You do have kept a backup did you? If you're not 100% sure everything will keep working it is better to comment lines out instead of deleting them.
Also the start of the commenting out should be after the first closing parenthesis in this line:
} elseif ($do_email) {
   $orderid = tep_db_query("SELECT order_id FROM " . TABLE_IDEAL_PAYMENTS . " WHERE payment_id='" . $paymentid . "'"); 
so it should read:
} /* elseif ($do_email) {
   $orderid = tep_db_query("SELECT order_id FROM " . TABLE_IDEAL_PAYMENTS . " WHERE payment_id='" . $paymentid . "'"); 

Any idea what the 'unexected $end' means?

I'm not sure on how to generate that. Probably something to do with the number of opening and closing parentheses not being the same or it could be a semi-colon ([bold];[/bold]) missing.

In a lot of PHP editors you can double-click next to a parenthesis and find out where the counterpart is. If it doesn't, it usually means there is something wrong with the code.

#93   Remco Leuven

Remco Leuven
  • Members
  • 11 posts
  • Real Name:Remco Leuven

Posted 09 June 2010 - 07:43

I backup every file before I start changing code.

No unexpected $end now :-) That was because I did remove the } in the
} elseif ($do_email) {
   $orderid = tep_db_query("SELECT order_id FROM " . TABLE_IDEAL_PAYMENTS . " WHERE payment_id='" . $paymentid . "'");
how stupid of me.

But iDeal order proceeds fine now, but still no email :-(

#94   nickibean

nickibean
  • Members
  • 2 posts
  • Real Name:nicki l

Posted 12 June 2010 - 23:58

first off thanks for all patience as I am very new at this.
I need to upgrade our osc site because host turned off global registry. I cannot see the site or get into admin.
I am using 2.2 ms2 cvs ... so I think I first need to upgrade to 2.2 ms2 060817? then to the current osc?
and I am using this link: http://www.oscommerc...te-20060817.txt
and as far as I can tell, I need to do this manually if I want to keep modifications.
if you could just let em know I'm on the right path I would so appreciate it!
Thanks!

#95   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 13 June 2010 - 07:57

I need to upgrade our osc site because host turned off global registry. I cannot see the site or get into admin.
I am using 2.2 ms2 cvs ... so I think I first need to upgrade to 2.2 ms2 060817? then to the current osc?
and I am using this link: http://www.oscommerc...te-20060817.txt
and as far as I can tell, I need to do this manually if I want to keep modifications.
if you could just let em know I'm on the right path I would so appreciate it!

With the update-20060817.txt you end up somewhere in the middle of the upgrade path in between 2.2 Milestone 2 (the version that was around for many years unchanged after 2.2 ms2 cvs [although your cvs might well be identical or close to Milestone 2 - ms2]). No point in using that first.

There is no upgrade path for the cvs version you might have to ms2 so this complicates matters. Instead of comparing every file in your installation with a new version to see if and where there are changes it might be quicker to see what contributions have been added to the shop and add those to a fresh install.

Then comparing the databases and making the changes to the old database to get to the latest version (there haven't been any major changes in ms2 to rc2a although I remember something about customer data tables changed).

#96   nickibean

nickibean
  • Members
  • 2 posts
  • Real Name:nicki l

Posted 13 June 2010 - 17:42

With the update-20060817.txt you end up somewhere in the middle of the upgrade path in between 2.2 Milestone 2 (the version that was around for many years unchanged after 2.2 ms2 cvs [although your cvs might well be identical or close to Milestone 2 - ms2]). No point in using that first.

There is no upgrade path for the cvs version you might have to ms2 so this complicates matters. Instead of comparing every file in your installation with a new version to see if and where there are changes it might be quicker to see what contributions have been added to the shop and add those to a fresh install.

Then comparing the databases and making the changes to the old database to get to the latest version (there haven't been any major changes in ms2 to rc2a although I remember something about customer data tables changed).


thank you for your quick reply! I am glad I asked...so I should do a fresh install, make adjustments and then compare the old database with new.
wish me luck! We had someone else setup our website so I am hoping I can do this.
thank you so much again for your help!!!

#97   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 13 June 2010 - 19:59

so I should do a fresh install, make adjustments and then compare the old database with new.

Of course you shouldn't do this on your live shop... Better on your own computer. Compare the database structure by making a backup without the data. Also from the backup of a fresh install. Then you can compare the differences. MySQL backups are text files so can you use a file comparison program to quickly spot differences.

Try to find out what contributions were installed on the old shop. Often the code of contributions is commented in the file that is changed so you get an idea what contribution that was. Most if not all contributions will still be around in the addon section for comparison.

#98   Robbogeordie

Robbogeordie
  • Members
  • 55 posts
  • Real Name:Chris

Posted 27 July 2010 - 16:38

Hi,
Thanks for this excellent contribution.
One thing that I can't seem to get fixed on my site is if I change currency from the base US$ to JPY (which doesn't have any decimals) then the currency is converted to an incorrect amount.I've put a zero in the decimals entry in admin like was suggested earlier in this thread and tried other combinations,but it keeps converting the price completely wrong.The only way to get the amount correct is to add a decimal place to the currency.
The currencies.php file is the same as the RC2a one.All the other currencies which have decimal places are fine - does anyone have any ideas what could be causing this,or a fix?
Thanks for any help.

#99   Jan Zonjee

Jan Zonjee

    Governor of Peace

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

Posted 27 July 2010 - 17:20

but it keeps converting the price completely wrong.

Like how and with what exchange rate? And was it working beforehand?

Never really looked at currency exchange rates so I don't know if I can be of help. But if nobody can recreate your problem the chances on a useful answer are even less...

#100   Robbogeordie

Robbogeordie
  • Members
  • 55 posts
  • Real Name:Chris

Posted 27 July 2010 - 17:51

Hi Jan,
Yes,it was working before.It's just the Japanese yen which doesn't have any decimals.The exchange figures are wayout.The only way for it to work correctly is if it is set it to 2 decimal places.Then it's fine.
If no one else is having this problem then please don't worry as it could be one of my contributions ..maybe salemaker or something.I'll let you know if I find out what was causing it.
Thanks for your quick reply.