• For a while now I have been encountering an issue that wordpress claims is causes by the Zita theme. Hopefully it isnt my fault!

    Thank you in advance to anyone who helps.

    Here is the email sent from wordpress:

    Howdy!
    
    WordPress has a built-in feature that detects when a plugin or theme causes a fatal error on your site, and notifies you with this automated email.
    
    In this case, WordPress caught an error with your theme, Zita.
    
    First, visit your website (https://www.k**.com/) and check for any visible issues. Next, visit the page where the error was caught (https://www.k**.com/wp-login.php) and check for any visible issues.
    
    Please contact your host for assistance with investigating this issue further.
    
    If your site appears broken and you can't access your dashboard normally, WordPress now has a special "recovery mode". This lets you safely login to your dashboard and investigate further.
    
    **************************link
    
    To keep your site safe, this link will expire in 1 day. Don't worry about that, though: a new link will be emailed to you if the error occurs again after it expires.
    
    When seeking help with this issue, you may be asked for some of the following information:
    WordPress version 6.2
    Active theme: Zita (version 1.6.0)
    Current plugin:  (version )
    PHP version 8.1.0
    
    
    
    Error Details
    =============
    An error of type E_ERROR was caused in line 194 of the file /home/*********/***********.com/wp-content/themes/zita/inc/woocommerce/woocommerce-common-function.php. Error message: Uncaught Error: Call to a member function get_total() on null in /home/*********/***********.com/wp-content/themes/zita/inc/woocommerce/woocommerce-common-function.php:194
    Stack trace:
    #0 /home/*********/***********.com/wp-content/themes/zita/inc/woocommerce/woocommerce-common-function.php(219): zita_cart_total_item()
    #1 /home/*********/***********.com/wp-content/themes/zita/inc/woocommerce/woocommerce-common-function.php(239): zita_cart_count_product()
    #2 /home/*********/***********.com/wp-includes/class-wp-hook.php(308): zita_menu_cart_view('')
    #3 /home/*********/***********.com/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
    #4 /home/*********/***********.com/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #5 /home/*********/***********.com/wp-content/themes/zita/inc/header-function.php(185): do_action('zita_cart_count')
    #6 /home/*********/***********.com/wp-includes/class-wp-hook.php(308): zita_main_header_markup('')
    #7 /home/*********/***********.com/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
    #8 /home/*********/***********.com/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #9 /home/*********/***********.com/wp-content/themes/zita/inc/themes-hooks.php(13): do_action('zita_main_heade...')
    #10 /home/*********/***********.com/wp-content/themes/zita/inc/header-function.php(850): zita_main_header()
    #11 /home/*********/***********.com/wp-content/themes/zita/header.php(103): zita_header_main_post_meta('')
    #12 /home/*********/***********.com/wp-includes/template.php(783): require_once('/home/nickkelle...')
    #13 /home/*********/***********.com/wp-includes/template.php(718): load_template('/home/nickkelle...', true, Array)
    #14 /home/*********/***********.com/wp-includes/general-template.php(48): locate_template(Array, true, true, Array)
    #15 /home/*********/***********.com/wp-content/themes/zita/404.php(10): get_header()
    #16 /home/*********/***********.com/wp-content/plugins/wp-cerber/cerber-load.php(4635): include('/home/nickkelle...')
    #17 /home/*********/***********.com/wp-content/plugins/wp-cerber/cerber-load.php(2448): cerber_404_page()
    #18 /home/*********/***********.com/wp-content/plugins/wp-cerber/cerber-load.php(2411): cerber_access_control()
    #19 /home/*********/***********.com/wp-includes/class-wp-hook.php(308): {closure}('')
    #20 /home/*********/***********.com/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
    #21 /home/*********/***********.com/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #22 /home/*********/***********.com/wp-settings.php(623): do_action('init')
    #23 /home/*********/***********.com/wp-config.php(95): require_once('/home/nickkelle...')
    #24 /home/*********/***********.com/wp-load.php(50): require_once('/home/nickkelle...')
    #25 /home/*********/***********.com/wp-login.php(12): require('/home/nickkelle...')
    #26 {main}
      thrown
    

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nickkelley177

    (@nickkelley177)

    Edit* I know i’m on the right track but don’t just copy and paste that code it will cause a critical error

    Looks like this may be the cause

    the function was trying to call the method get_total() on a null value, which meant that the global variable $woocommerce was not set. The bug was that the code was not checking to see if WooCommerce was activated before trying to access the $woocommerce global variable.

    starting at line 191 on the original

     function zita_cart_total_item(){
       global $woocommerce; 
       $zita_woo_cart_disable = get_theme_mod('zita_woo_cart_disable','icon'); 
       $ordertotal       = wp_kses_data( $woocommerce->cart->get_total() );
       $productadd       = wp_kses_data($woocommerce->cart->cart_contents_count);
      ?>
      

    and what *hopefully* will be the fix

    if ( zita_is_woocommerce_activated() ){

     function zita_cart_total_item(){
      if ( zita_is_woocommerce_activated() ){
       global $woocommerce; 
       $zita_woo_cart_disable = get_theme_mod('zita_woo_cart_disable','icon'); 
       $ordertotal       = wp_kses_data( $woocommerce->cart->get_total() );
       $productadd       = wp_kses_data($woocommerce->cart->cart_contents_count);
      ?>
      
    erniecom

    (@erniecom)

    Not sure if this is already fixed in Zita, but I experienced this same issue in another theme. I am only contributing my thoughts here.

    I wonder if zita_is_woocommerce_activated is sufficient. Woocommerce is always active in my case and apparently even then there can be occasions that the global object variable or parts there of (cart) are null. It is more thorough to check the existence of the object.

    To be sure I am going to try is_object($woocommerce->cart) as test before using the methods get_totals or cart_content_counts, as suggested in other forum posts.

    • This reply was modified 1 year ago by erniecom.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Reoccurring issue causes site crash’ is closed to new replies.