FYI, when I add this line
$settings = json_decode(json_encode($settings), true);
in this file
\wp-content\plugins\fluid-checkout\inc\admin\admin.php
the error will be fix.
if any other solution then please update here as well as in plugin.
Hi @webdevloper21,
The WooCommerce $settings parameter is supposed to be of type Array instead of WC_Settings_CYP, it is likely that another plugin or theme is incorrectly changing that parameter type.
Please check on your website for the plugin which defines the class WC_Settings_CYP, and contact the plugin author to check and fix this issue on their end.
To prevent the “Fatal Error” we’ve added verification of the $settings parameter type on our plugin as seen below, which will be available in the next update (v.1.2.6):
/**
* Add new WooCommerce settings pages/tabs.
*/
public function add_settings_pages( $settings ) {
// Bail if settings not an array
if ( ! is_array( $settings ) ) { return $settings; }
$settings[] = include self::$directory_path . 'inc/admin/admin-settings-wc-shipping.php';
$settings[] = include self::$directory_path . 'inc/admin/admin-settings-checkout.php';
return $settings;
}
This change will prevent the “Fatal Error” but will also make the Fluid Checkout settings unavailable. We’ve also added this information on the readme.txt.
Best,
Diego
Why you are not using this $settings = json_decode(json_encode($settings), true); as with this line we could access plugin setting also ?
Hi @webdevloper21,
The solution proposed is not ideal. The reasoning is that the $settings parameter is supposed to be an array, not anything else.
Whenever add_filter is used, it is expected that the return value has the same type as the passed-in parameter.
Check the WooCommerce variable declaration and the correct way of adding new features to these settings in the WooCommerce code at:
https://github.com/woocommerce/woocommerce/blob/trunk/includes/admin/class-wc-admin-settings.php#L48
Adding the json_encode and json_decode will make the plugin unnecessarily slower (probably by just a few milliseconds), and can potentially break something else.
We believe bugs should be fixed at their “root” cause, otherwise, the “weeds” will keep growing over time.
If you do not have the option to look into the conflicting plugin and contact their respective developers, you can still unhook the Fluid Checkout’s function add_settings_pages and hook a modified version of it. Although we strongly discourage that.
Best,
Diego
How do I do that? could you please give me code(hook) to add in function.php ?
Hi @webdevloper21,
Again, we strongly discourage the use of this method for the reasons mentioned on this thread…
The hook is woocommerce_get_settings_pages, here is the code to remove the Fluid Checkout hooked function:
if ( class_exists( 'FluidCheckout_Admin' ) ) {
remove_filter( 'woocommerce_get_settings_pages', array( FluidCheckout_Admin::instance(), 'add_settings_pages' ), 50 );
}
After that, you can hook in your modified version of the function, which code will depend on your implementation.
Best,
Diego
Hi @webdevloper21,
I’ve just released a new version (1.2.7) that should fix the “fatal error” and still display the plugin’s settings.
I’m closing this thread for now. Few free to re-open it if you still experience this issue.
Best,
Diego