Home Forums WoodMart support forum Error from woodmart template-tags file

Error from woodmart template-tags file

Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #127834

    keizershaquil
    Participant

    Hi,
    I noticed that my webiste is slow and sometimes it gives me a 502 error. After that I read the php error logs and there are two error that appear in almost every line of the file:
    – in_array() expects parameter 2 to be array, null given in /www/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php on line 1769
    – Trying to get property ‘roles’ of non-object in /www/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php on line 1761

    Is there anyway to solve it?

    #127855

    Artem Temos
    Keymaster

    Hello,

    Could you please disable all plugins that are not related to our theme and provide us your admin access so we can check it? Also, send us access to your error logs so we see them.

    Thank you in advance

    #129004

    keizershaquil
    Participant

    Hi,
    I found out that the 502 error was being caused by Woocommerce Admin plugin. But the template tag error is still appearing in recent logs.

    #129054

    keizershaquil
    Participant

    .

    #129027

    Artem Temos
    Keymaster

    Could you please disable all plugins that are not related to our theme and provide us your admin access so we can check it? We need access to your error logs live since we have to check if they appear after some changes.

    #129184

    keizershaquil
    Participant

    Hi,
    I made a exact copy of my website to my staging and you can make the tests there.

    Have a nice day,
    Eunice Vassoa

    #129192

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file

    function woodmart_my_account_navigation( $items ) {
    		$user_info = get_userdata( get_current_user_id() );
    		$user_roles = property_exists( $user_info, 'roles' ) ? $user_info->roles : array();
    
    		unset( $items['customer-logout'] );
    
    		if ( class_exists( 'YITH_WCWL' ) ) {
    			$items['wishlist'] = get_the_title( yith_wcwl_object_id( get_option( 'yith_wcwl_wishlist_page_id' ) ) );
    		}
    
    		if ( class_exists( 'WeDevs_Dokan' ) && apply_filters( 'woodmart_dokan_link', true ) && ( in_array( 'seller', $user_roles ) || in_array( 'administrator', $user_roles ) ) ) {
    			$items['dokan'] = esc_html__( 'Vendor dashboard', 'woodmart' );
    		}
    	
    		$items['customer-logout'] = esc_html__( 'Logout', 'woodmart' );
    
    		return $items;
    	}
    
    	add_filter( 'woocommerce_account_menu_items', 'woodmart_my_account_navigation', 15 );
    #129368

    keizershaquil
    Participant

    Hi,
    I checked the logs an now it gives me a different warning: PHP Warning: First parameter must either be an object or the name of an existing class in /www/wp-content/themes/woodmart-child/functions.php on line 504
    Line 504 has the following code: $user_roles = property_exists( $user_info, ‘roles’ ) ? $user_info->roles : array();
    Can I get a hand with this too, please.

    Have a nice day,
    Eunice Vassoa

    #129394

    Artem Temos
    Keymaster

    Try to replace that line with the following one

    $user_roles = ( $user_info && property_exists( $user_info, 'roles' ) ) ? $user_info->roles : array();

    #129433

    keizershaquil
    Participant

    It is still giving the same message.

    #129435

    Artem Temos
    Keymaster

    Could you please send us a step by step instruction how to reproduce the error and send us your admin and FTP access?

    #129522

    keizershaquil
    Participant

    The error is simply showing in the php logs.
    I think it just shows everytime a page is reloaded or an action is executed.

    #129533

    Artem Temos
    Keymaster

    We have to be able to check your error logs live to understand if the problem fixed or not.

    #129614

    keizershaquil
    Participant

    Hi,
    Can you please provide me an email that I can use to create a user so you can have live access to the logs?

    #129615

    Artem Temos
    Keymaster

    You can use this email

    #129737

    keizershaquil
    Participant

    Hi,
    Sorry for the late reply. I sent an invitation to that email account so you can join the collaboration team and have access to the logs.

    Have a nice day,
    Eunice Vassoa

    #129742

    Artem Temos
    Keymaster

    We don’t see the error now.

    #130280

    keizershaquil
    Participant

    Hi,
    It’s strange because I didn’t do nothing special.
    Since the issue is gone I think this ticket can be closed now.

    Have a nice day,
    Eunice Vassoa

    #130281

    Artem Temos
    Keymaster

    You are welcome.

Tagged: 

Viewing 19 posts - 1 through 19 (of 19 total)