Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted (edited)

In the official instruction for the manual install of Paypal API 2.0 in osCommerce 2.2. , the following is asked to be added in /classes/payment.php

 

c) about line 142 (156) find
and insert before
function pre_confirmation_check() {
/// paypal_rest (from osc23)

 function checkout_initialization_method() {

 $initialize_array = array();


 if (is_array($this->modules)) {

 reset($this->modules);

 while (list(, $value) = each($this->modules)) {

 $class = substr($value, 0, strrpos($value, '.'));

 if ($GLOBALS[$class]->enabled && method_exists($GLOBALS[$class],

'checkout_initialization_method')) {

 $initialize_array[] = $GLOBALS[$class]->checkout_initialization_method();

 }

 }

 }

return $initialize_array;

 }

The highlighted line is invaild PHP since PHP8 and fails with fatal error. It should be replaced by

 

foreach ($this->modules as $value) {

 

Of course, the original code for osC 2.2. is invalid in many places these days as well, but our cart has always been upgraded to the latest PHP and mySQL versions over the years, and one should expect that the new installation instructions for apps should reflect the present status of PHP.

 

 

 

Edited by Thomas789
Posted

As you mentioned, that package is for oscommerce 2.2. That oscommerce version is not qualified to run on any version above php 5.4, if that. So if the code in the paypal package was coded with code that works for php 8x, it would probably fail since some php code is not backward compatible.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted (edited)
21 hours ago, Jack_mcs said:

As you mentioned, that package is for oscommerce 2.2. That oscommerce version is not qualified to run on any version above php 5.4, if that. So if the code in the paypal package was coded with code that works for php 8x, it would probably fail since some php code is not backward compatible.

 

The PHP foreach() construct is backward compatible with PHP 4 even.

 

Another issue I noticed is the missing class constructor in classes where the function name is identical to the class name. So it should be for instance


 

class paypal_rest extends PaypalPartnerTrait {

    var $code, $title, $description, $enabled;
    
         // class constructor
    function __construct() {
          $this->paypal_rest();
    }  
    

    function paypal_rest() {

Without the added class constructor method, this fails with fatal error in PHP8.  This is backward compatible with PHP5 at least as well.

Edited by Thomas789
Posted

You're looking at it backwards. If i am coding an addon for a 2.2 shop, I would code it using php for that version - 5.3, maybe 5.4. To try to code it for some future version of php is just asking for problems. The parts you mention are compatible, but some other function may not be. So, I would need to create two versions: one for the intended shops and one for those like you, assuming I used code that was not compatible between the various versions. Since my imaginary addon is being written for free, why should I go to so much effort to cover cases where the shops code has been altered? Look at just about any old addon and the instructions will mention that the changes are for a stock shop. This is no different.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

  • 1 month later...
Posted

I have been making good progress in the meanwhile having the code for this oscommerce 2.2. addon upgraded to PHP8, but I have hit a roadblock at the moment trying to insert my Paypal API credentials. When I click the 'Edit' button for the settings of this module, I am getting the screen as shown in the attachment, but when I click the 'Click here to configure' link for the API configuration, nothing happens. I figured out that this should result in a popup window via jquery, but apparently something does not work correctly here.  The PHP error log shows me only the following warnings after clicking the 'Edit' button on modules.php

 

[Mon Jun 03 14:18:28.264480 2024] [php:notice] [pid 16368:tid 1896] [client ::1:60332] PHP Notice:  Credentials are not defined in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalMiddleWare.php on line 148
[Mon Jun 03 14:18:28.342601 2024] [php:warn] [pid 16368:tid 1896] [client ::1:60332] PHP Warning:  Undefined variable $cancelUrl in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalPartner\\views\\extra.php on line 29
[Mon Jun 03 14:18:28.342601 2024] [php:warn] [pid 16368:tid 1896] [client ::1:60332] PHP Warning:  Undefined array key "setup" in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalPartner\\views\\extra.php on line 56
[Mon Jun 03 14:18:28.342601 2024] [php:warn] [pid 16368:tid 1896] [client ::1:60332] PHP Warning:  Undefined array key "setup" in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalPartner\\views\\extra.php on line 58
[Mon Jun 03 14:18:28.342601 2024] [php:warn] [pid 16368:tid 1896] [client ::1:60332] PHP Warning:  Undefined property: PaypalPartner\\models\\SellerInfo::$isNewRecord in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalPartner\\views\\extra.php on line 72
[Mon Jun 03 14:18:28.342601 2024] [php:warn] [pid 16368:tid 1896] [client ::1:60332] PHP Warning:  Undefined array key "ppp_next" in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalPartner\\views\\extra.php on line 345
[Mon Jun 03 14:18:28.342601 2024] [php:warn] [pid 16368:tid 1896] [client ::1:60332] PHP Warning:  Undefined array key "ppp_next" in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalPartner\\views\\extra.php on line 345
[Mon Jun 03 14:18:28.342601 2024] [php:warn] [pid 16368:tid 1896] [client ::1:60332] PHP Warning:  Undefined array key "ppp_next" in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalPartner\\views\\extra.php on line 440
[Mon Jun 03 14:18:28.342601 2024] [php:warn] [pid 16368:tid 1896] [client ::1:60332] PHP Warning:  Undefined array key "setup" in C:\\xampp\\htdocs\\sheldon_test\\includes\\modules\\payment\\paypal_rest\\PaypalPartner\\views\\extra.php on line 443

 

Most of these relate to the file  extra.php in PaypalPartner/views but I am not sure whether they have anything to do with my problem. Having said this, there was in obvious mistake in the original code for extra.php, because on line 58 it said

 

if ($smarty . get . setup == 1) {

I suppose this was copied over from a different software package as it does not appear to be valid PHP syntax and a variable $smarty is not defined anywhere., so it does not make any sense at all to me. With this, I was actually not able to access the 'Edit' screen at all. So I changed this now to

 

if ($_GET['setup'] == 1) {

 

which gets me now into the Edit screen as shown but still leaves me with the problem of not being able to insert my API credentials as the link for this does not work.

 

screenshot.jpg

  • 9 months later...
Posted (edited)

Yes, the update is a bit careless. I don't know how anyone comes up with the idea that an automatic update could work in osCommerce 2.x. Unfortunately, the procedure for a manual update cannot work either.
Instead of:
if ($smarty . get . setup == 1) {
please write
if (isset($_GET['setup']) && $_GET['setup'] == 1) {

The "Notice" message is from level E_USER_NOTICE and you should ignore it at this time.
There are an incredible number of pitfalls in this update! This also includes some elements from Smarty in the output Javascript.
Please look aout for curly brackets like "{$"

Edited by IngoPhisto

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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