Ecommerce Shopify WordPress Discussion

Warning: count(): Parameter must be an array or an object that implements Countable in (\:directory) on line 436 [duplicate]

This question already has answers here: Reference - What does this error mean in PHP? (38 answers) phpmyadmin - count(): Parameter must be an array or an object that implements Countable (40 answers) Closed 11 days ago. I'm getting this error in Wordpress and I don't know what it's asking. Here is the code starting on line 436. if (count($this->keys) && $this->action == 'add') { // Extract the last key $last = $this->keys[count($this->keys) - 1]; // Are we trying to add stuff? if ($last == $this->add_key) { $this->data = $this->set_data($this->default, $this->keys); } } Its in a plug in called 'more fields. Its updated. I don't know what to try. PHP isn't my forte.
Arrays, Generators, Objects (with public properties) and Iterators are implementing the Countable Interface. If it is not one of those types you will get this error. To fix this error you can check if it is countable. if (is_countable($this->keys) && count($this->keys) && $this->action == 'add')

December 30, 2023

Well, ChatGPT pointed out that $this->keys Might not be an array in some contexts. I would have never guessed that, but PHP isn't my forte. ChatGPT suggested checking to see if it was an array before implementing. The fix: if (is_array($this->keys) && count($this->keys) && $this->action == 'add') { // Extract the last key $last = $this->keys[count($this->keys) - 1]; // Are we trying to add stuff? if ($last == $this->add_key) { $this->data = $this->set_data($this->default, $this->keys); } } Looks to be working and implemented well with the old plug in. If there is anything anyone else would like to point out, I'm all ears and willing to learn. Thank you.

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.