How to fix themify theme warning on theme-function.php file
Today I got a call from one of our UAE client. He is having one e-commerce website. He wants to fix one warning error on their website. and I just checked their website I can see one warning error that related to theme function file. And I did google search then I found a lot of website having these warning errors. Finally, we fixed that warning error. Here I just want to share my code.
The following website I can see the error
https://www.snowmasters.com/shop/
http://crescendo-graphics.com/
https://www.proboats.org/product-category/kayaks/
https://carigary.com/product/daily-jewelry/
https://southtownriders.com/lessons/
http://listeningafrica.com.ng/product/the-walkers/
https://www.oklahomacycling.com/product-category/the-jerseys
Below I have mentioned existing code and changed the code. So you have to change the code in theme-function.php file.
Old code
function themify_woocommerce_params($params){
return array_merge($params, array(
‘option_ajax_add_to_cart’ => ( ‘yes’ == get_option(‘woocommerce_enable_ajax_add_to_cart’) )? ‘yes’: ‘no’
) );
}
New code
function themify_woocommerce_params($params){
if(is_array($params)){
return array_merge($params, array(
‘option_ajax_add_to_cart’ => ( ‘yes’ == get_option(‘woocommerce_enable_ajax_add_to_cart’) )? ‘yes’: ‘no’
) );
}else{
return array(
‘option_ajax_add_to_cart’ => ( ‘yes’ == get_option(‘woocommerce_enable_ajax_add_to_cart’) )? ‘yes’: ‘no’
);
}
}
Thanks