VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: lumares on April 09, 2020, 16:47:47 PM

Title: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: lumares on April 09, 2020, 16:47:47 PM
Since the last updates we get a "Cannot use object of type stdClass as array" error when I go to checkout and choose a payment method.

We are running:
Joomla 3.9.16
Virtuemart 3.6.10 10211
Payments via: VM modules and RO payments (v 5.2.0)

Problem:
In checkout when we choose a payment method, error "Cannot use object of type stdClass as array" appears.
Before the updates everything was working fine.

Troubleshooting:
We already contacted the ro payments and they did some checking.

Quote"The error basically says it fails in the function checkForCartQuantities on line 2030 in the file components/com_virtuemart/helpers/cart.php."

Also see attachement.

Any help would greatly be appreciated.
S.

Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: pinochico on April 09, 2020, 17:13:12 PM
I think problem is mybe in paymet plugin RO == contact payment plugin developer
Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: lumares on April 09, 2020, 17:49:55 PM
Yes, that is exaclty what I did. They said it has to be Virtuemart.
Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: GJC Web Design on April 09, 2020, 20:08:20 PM
QuoteYes, that is exaclty what I did. They said it has to be Virtuemart.

well .. if they can't be bothered to update their plugin for new versions then it tells u a lot about their commitment to their clients and VM

switch on Joomla debug and u should get a stack trace to show u exactly where the error is being thrown
Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: lumares on April 10, 2020, 15:25:11 PM
They did help, this is the exact statement I got from Ro payments, after his research (screenshot is the one above):

QuoteHello Steven,

I have taken a look and it is not an RO Payments problem as the error is generated in the VirtueMart code. Attached is the screenshot from the site. This doesn't happen when I click checkout but it happens for me when I click a payment method.

In that case it may be related to the OPC but that is for VirtueMart to tell you as I have no idea about that. The error basically says it fails in the function checkForCartQuantities on line 2030 in the file components/com_virtuemart/helpers/cart.php.

I just don't know what to do with this info; To be honest I don't know what OPC is?

I do have backups etc... but after updating the same happens. We are always strickt in updating our all Joomla sites and plugins.
I also disabled the whole RO payments plugin and only enabled VM COD and VM bank transfer. Same thing happens.

when selecting a payment method the error appears.

When I enable debug, I can't get any further then the homepage?

I can post the link to the site if you want or pm.

Any help is greatly appreciated.
Steven

Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: GJC Web Design on April 10, 2020, 23:03:29 PM
OPC = One Page Checkout

r u using a 3rd party checkout?

so it happens on any payment method?

that line is

if($quantity!=$this->cartProductsData[$key]['quantity']){

so check what are the values of the vars  ... esp  $this->cartProductsData

should be an array

Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: pinochico on April 11, 2020, 01:12:06 AM
QuoteI also disabled the whole RO payments plugin

I think Virtuemart load any payments plugins even if disabled in the cart (initializes them). If this true, then RO plugin error in cart persists :(
We delete all payments plugin if we don't need.
Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: lumares on April 14, 2020, 13:09:57 PM
Quote from: GJC Web Design on April 10, 2020, 23:03:29 PM
OPC = One Page Checkout

r u using a 3rd party checkout?

so it happens on any payment method?

that line is

if($quantity!=$this->cartProductsData[$key]['quantity']){

so check what are the values of the vars  ... esp  $this->cartProductsData

should be an array

Thank you for the tips, I have disabled OPC. -> Now the error happens when I click on "submit order".

So now I did a complete back-up restore and I am updating plugin per plugin to find the culprit.

1) Working & already updated site/shop with only VM and RO updates left open to be updated. > at this moment the shop is working as it should.
2) I Install the VM update and get an error: "Class 'vmPSPlugin' not found" -> now I get error "Cannot use object of type stdClass as array"

So the causing problem seems to do with Class 'vmPSPlugin' not found during the vm update.

PHP max execution is 60 and max men 128M , max file 512M

So at this point RO payments isn't even installed yet.
Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: jenkinhill on April 14, 2020, 13:41:22 PM
Did you update both the VM component and the associated aio package?

Do you have any other third party VM plugins installed (apart from OPC)?
Title: Re: "Cannot use object of type stdClass as array" when choosing a payment method
Post by: pinochico on April 14, 2020, 14:37:30 PM
Quote2) I Install the VM update and get an error: "Class 'vmPSPlugin' not found" -> now I get error "Cannot use object of type stdClass as array"

Virtuemart hase bug and not initialized vm model in payment or shipment plugins.
For this we must upgraded our gopay payment plugin and vm standard shipping plugin and add some code for loading some class.
I don't know what is with new version 3.6.10 and higher, but I think change wotking with loading models and class (we must upgraded VirtueMart Mailing Manager too).

So for this moment you must upgrade RO payment plugin.
Definitelly.

Yre you another question? :D