Issue with the API request after the latest update of the theme
-
After updating the woodmart theme, we are facing some issues in API. Below HTML is getting printed before JSON response and breaking API functionality of our mobile app
<link rel=”stylesheet” id=”wd-int-el-animations-css” href=”https://pkkicks.org/wp-content/themes/woodmart/css/parts/int-wbp-el-animations.min.css?ver=6.5.2″ type=”text/css” media=”all” />
this is a sample route to get product details in our mobile app
https://pkkicks.org/?api_key=LFwfaYFId9DVcCxcup1CFEA8024owQAJ&rest_route=%2Fappmaker-wc%2Fv1%2Fproducts%2F3053
and you can see the html at the beginning of this response
we have seen a similar situation in your support forum but couldn’t find the solution over there. Is this already resolved?
https://xtemos.com/forums/topic/api-unexpected-character-encountered-while-parsing-value/
Hello,
Could you please disable all plugins that are not related to our theme and provide us your admin and FTP access so we can check it?
Thank you in advance
Hello,
we cannot disable appmaker plugin since that rest route is required to check the issue
We havedisabled all other plugins. FTP and admin provided in private content
Thanks
Attachments:
You must be
logged in to view attached files.
Try to add the following PHP code snippet to the child theme functions.php file to fix this
if ( ! function_exists( 'woodmart_change_is_rest_api' ) ) {
/**
* This feature will add rest api validation to support rest_route.
*
* @return bool
*/
function woodmart_change_is_rest_api() {
return ( false !== strpos( $_SERVER['REQUEST_URI'], 'rest_route' ) );
}
add_filter( 'woocommerce_is_rest_api_request', 'woodmart_change_is_rest_api' );
}
Kind Regards