This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing a fatal error when loading a variable product in the REST API, but not with a simple product. The error message indicates an issue with calling a member function on an array within the WooCommerce Multilingual plugin. Solution: We recommend deactivating all third-party plugins except for WooCommerce and WPML-related ones, and switching to a default theme like Twenty Twenty-Two to isolate the issue. This approach helped confirm that the problem might be caused by either a conflicting plugin or the theme currently active on your site. If this resolves the issue, you can reactivate each plugin one by one to identify the specific cause of the conflict.
Please note that this solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket for further assistance at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Background of the issue:
I get an error when I load a variable product in the REST API, but I do not get an error with a simple product. The error is: Fatal error: Uncaught Error: Call to a member function get_params() on array in /home/saharabh/public_html/wp-content/plugins/woocommerce-multilingual/classes/Rest/Wrapper/Products/Products.php:65 Stack trace: #0 /home/saharabh/public_html/wp-includes/class-wp-hook.php(324): WCMLRestWrapperProductsProducts->prepare(Object(WP_REST_Response), Object(WC_Product_Variation), Array) #1 /home/saharabh/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Object(WP_REST_Response), Array) #2 /home/saharabh/public_html/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-variations-controller.php(168): apply_filters('woocommerce_res...', Object(WP_REST_Response), Object(WC_Product_Variation), Array) #3 /home/saharabh/public_html/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-crud-controller.php(143): WC_REST_Product_Variations_Controller->prepare_object_for_response(Object(WC_Product_Variation), Array) #4 /home/saharabh/public_html/wp-content/plugins/wepos/includes/REST/Manager.php(74): WC_REST_CRUD_Controller->get_item(Array) #5 /home/saharabh/public_html/wp-includes/class-wp-hook.php(324): WeDevsWePOSRESTManager->product_response(Object(WP_REST_Response), Object(WC_Product_Variable), Object(WP_REST_Request)) #6 /home/saharabh/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Object(WP_REST_Response), Array) #7 /home/saharabh/public_html/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php(192): apply_filters('woocommerce_res...', Object(WP_REST_Response), Object(WC_Product_Variable), Object(WP_REST_Request)) #8 /home/saharabh/public_html/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-crud-controller.php(143): WC_REST_Products_V2_Controller->prepare_object_for_response(Object(WC_Product_Variable), Object(WP_REST_Request)) #9 /home/saharabh/public_html/wp-includes/rest-api/class-wp-rest-server.php(1230): WC_REST_CRUD_Controller->get_item(Object(WP_REST_Request)) #10 /home/saharabh/public_html/wp-includes/rest-api/class-wp-rest-server.php(1063): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wc/v2/products...', Array, NULL) #11 /home/saharabh/public_html/wp-includes/rest-api/class-wp-rest-server.php(439): WP_REST_Server->dispatch(Object(WP_REST_Request)) #12 /home/saharabh/public_html/wp-includes/rest-api.php(420): WP_REST_Server->serve_request('/wc/v2/products...') #13 /home/saharabh/public_html/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP)) #14 /home/saharabh/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #15 /home/saharabh/public_html/wp-includes/plugin.php(565): WP_Hook->do_action(Array) #16 /home/saharabh/public_html/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array) #17 /home/saharabh/public_html/wp-includes/class-wp.php(813): WP->parse_request('') #18 /home/saharabh/public_html/wp-includes/functions.php(1336): WP->main('') #19 /home/saharabh/public_html/wp-blog-header.php(16): wp() #20 /home/saharabh/public_html/index.php(17): require('/home/saharabh/...') #21 {main} thrown in /home/saharabh/public_html/wp-content/plugins/woocommerce-multilingual/classes/Rest/Wrapper/Products/Products.php on line 65
Symptoms:
Fatal error: Uncaught Error: Call to a member function get_params() on array in /home/saharabh/public_html/wp-content/plugins/woocommerce-multilingual/classes/Rest/Wrapper/Products/Products.php:65
Questions:
How can I resolve the error when loading a variable product in the REST API?
The website copy process is finished, Upon the initial troubleshooting I deactivated all third-party plugins except Woocommerce and WPML-related ones, also enabled the default 2022 theme, and there is no issue retrieving the variable product:
hidden link
Please use the same login information of your website and login here to see:
hidden link
This shows that either a plugin or the theme of your website causes the issue.
i was able to get the cause of this issue and i resolved it
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.