Skip Navigation

[Resolved] Getting error: Cannot access offset of type string on string

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by catherineR-2 1 year, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2558937

Tell us what you are trying to do?
We haven't changed anything on our site in ages relating to our Toolset Types fields, but we're suddenly getting errors from Toolset types.

Is there any documentation that you are following?
No

Is there a similar example that we can see?
No

What is the link to your site?
N/A. The error appears when someone tries to pay for an order through WooCommerce. For some reason Toolset Types is trying to do something with the fields we added to orders. Not sure why Toolset is doing something during the checkout phase, since the fields we added are only for the backend.

This is the error we're getting all of sudden:

Uncaught TypeError: Cannot access offset of type string on string in /www/gangaji_212/public/wp-content/plugins/types/application/models/field/mapper/abstract.php:125
Stack trace:
#0 /www/gangaji_212/public/wp-content/plugins/types/application/models/field/type/select/mapper/legacy.php(45): Types_Field_Mapper_Abstract->apply_options_filter(Array, Array)
#1 /www/gangaji_212/public/wp-content/plugins/types/application/models/field/service.php(54): Types_Field_Type_Select_Mapper_Legacy->find_by_id('gf-order-type', 3380051)
#2 /www/gangaji_212/public/wp-content/plugins/types/application/models/field/group/mapper/legacy.php(55): Types_Field_Service->get_field(Object(Types_Field_Gateway_Wordpress_Post), 'gf-order-type', 3380051)
#3 /www/gangaji_212/public/wp-content/plugins/types/application/models/post/builder.php(36): Types_Field_Group_Mapper_Legacy->find_by_post(Object(WP_Post), 9999)
#4 /www/gangaji_212/public/wp-content/plugins/types/application/models/post/deletion.p" while reading response header from upstream, client: 69.181.161.91, server: gangaji.org, request: "POST /?wc-ajax=checkout HTTP/1.1", upstream: "hidden link:", host: "gangaji.org:21331", referrer: "hidden link"

#2559939

Hello,

I have tried it in a fresh WP installation + the latest version of Toolset plugins + Woocommerce plugin, but don't see the problem.

See below test site:
Login URL: hidden link

Custom select field in post type "Order":
hidden link

In frontend:
hidden link
I can complete the checkout without any issue.

Is there any missing steps? Can you reproduce the same problem in above test site?

#2560341

We are using the filter wpt_field_options and that might be causing the problem. In the documentation, it says not to use that filter anymore, but I can't find a replacement. What is the current filter or hook to alter the items in a drop down types field?

#2560523

No, there isn't new filter hook.

Since you just need it work in admin side, you can use WordPress function is_admin() to check if it is admin side, then trigger your custom PHP codes, for example:

if ( ! is_admin() ) {
    echo "You are viewing the theme";
} else {
    echo "You are viewing the WordPress Administration Panels";
}

More help:
https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options

#2561039

Also looks like our function is old, returning the old format in the filter instead of with #value, #title keys. Now with PHP 8, it's a fatal error instead of a warning.

This is resolved now. Thanks for your assistance!

#2561041

My issue is resolved now. Thank you!

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.