Forums / Built-in Shipping and Payment Modules / Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

Views: 1,066

Results 1 to 7 of 7
12 Aug 2017, 6:56 AM
#1
mikemc24 avatar

mikemc24

New Zenner

Join Date:
Feb 2016
Location:
UK
Posts:
8
Plugin Contributions:
0

Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

ZC version 1.54 PHP Version 5.6.31 Official Sagepay Integration - Version: 1.0

Logging the following PHP warning

[12-Aug-2017 06:37:20 Europe/London] PHP Warning: Illegal string offset 'id' in /var/www/vhosts/laptopstands.co.uk/heightadjustabledesks.solutions/includes/modules/payment/sagepay_zc/sagepay_zc_payment.php on line 85

Line 85 starts $sql =

Googling the warning infers it is something introduced in PHP 5.4 and to do with strings that should be arrays, don't really know myself, is there a solution to this please.

    public function update_status()
    {
        global $order, $db;
        if ($this->enabled == false || (int)$this->getModuleDefineValue('_ZONE') == 0) {
            return;
        }
        $check_flag = false;
        $sql = "SELECT zone_id FROM " . TABLE_ZONES_TO_GEO_ZONES . " WHERE geo_zone_id = '" . (int)$this->getModuleDefineValue('_ZONE') . "' AND zone_country_id = '" . (int)$order->billing['country']['id'] . "' ORDER BY zone_id";
        $checks = $db->Execute($sql);
        foreach ($checks as $check) {
            if ($check['zone_id'] < 1) {
                $check_flag = true;
                break;
            } elseif ($check['zone_id'] == $order->billing['zone_id']) {
                $check_flag = true;
                break;
            }
        }
        if ($check_flag == false) {
            $this->enabled = false;
        }
    }
12 Aug 2017, 11:24 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

Given the code you posted, an error like that should only occur if there's no "order", or the order has no "country" assigned to the "billing address".
But if you're in the middle of checkout, that shouldn't ever be the case.

When exactly is the error happening?
What plugins do you have installed to your site? (especially any that alter the default checkout flow)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Aug 2017, 10:27 AM
#3
mikemc24 avatar

mikemc24

New Zenner

Join Date:
Feb 2016
Location:
UK
Posts:
8
Plugin Contributions:
0

Re: Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

Orders are fully processed without a problem, only have one zone, United Kingdom on freeshiper. Going through the process there is no warning until the order is viewed from the admin panel.

Freeshiper goes to an orange status if the United Kingdom is set up as the zone so its left as no zone. That may be the issue, I will have to have a look.

16 Aug 2017, 8:33 PM
#4
mikemc24 avatar

mikemc24

New Zenner

Join Date:
Feb 2016
Location:
UK
Posts:
8
Plugin Contributions:
0

Re: Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

I think that the reason for this warning is that in the table zones to geo zones the zone id is null.

Can someone tell me please how this field should get populated with a zone id and if the field is not populated with a zone id would it be the reason for the warning.

16 Aug 2017, 9:18 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

mikemc24:

I think that the reason for this warning is that in the table zones to geo zones the zone id is null.

Can someone tell me please how this field should get populated with a zone id and if the field is not populated with a zone id would it be the reason for the warning.
No. As I look at it, there might be a bug in the module.

In your SagePay module settings, what's your Payment Zone set to? Have you left it at --none-- so that it applies to everyone? Or have you set it to something else, in order to restrict its use to people in certain countries only? I suspect you've changed it from "--none--" to something else. Does changing it to --none-- solve the problem?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Aug 2017, 5:54 AM
#6
mikemc24 avatar

mikemc24

New Zenner

Join Date:
Feb 2016
Location:
UK
Posts:
8
Plugin Contributions:
0

Re: Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

Yes, changing the payment zone from United Kingdom to none resolves the issue of the PHP warning and as we only ship to UK there is no impact, thank you.

17 Aug 2017, 6:00 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Official Sagepay Integration - PHP Warning: Illegal string offset 'id'

mikemc24:

Yes, changing the payment zone from United Kingdom to none resolves the issue of the PHP warning and as we only ship to UK there is no impact, thank you.
Thanks for reporting back.

We'll look into addressing what appears to be a bug that triggers the error you mentioned, only under the specific circumstance.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.