Home › Forums › WoodMart support forum › Bugs (Table Rate Shipping & author archives)

Bugs (Table Rate Shipping & author archives)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #730512

    dtech10
    Participant

    rebuilding the sites in a staging environment so far and we’ve discovered 2 bugs isolated to woodmart and confirmed by ensuring only woodmart and woocommerce are enabled, and Claude confirmed as well. I am pasting the details below:

    Everything below was reproduced on our **staging site**, not the live store. Each issue was isolated by **deactivating every other plugin**: only WooCommerce stayed active, plus WoodMart Core and Table Rate where noted.

    **Environment:**
    – WordPress 7.1.2
    – WooCommerce 11.1.2
    – WoodMart 8.6.2, WoodMart Core 1.1.9
    – WooCommerce Table Rate Shipping 3.7.4
    – PHP 8.5.3, Apache

    —

    ### Issue 1: Fatal error when opening the WoodMart Cart layout in the block editor (WoodMart + Table Rate Shipping)

    **What happens**
    Opening our Cart layout (WoodMart → Layouts → Cart) in the block editor gives “There has been a critical error on this website”, and the editor never loads. The storefront cart works normally.

    **Isolation (staging site)**
    | Active plugins | Result |
    | WooCommerce + Table Rate Shipping + WoodMart Core only (WoodMart theme) | **Fatal error** |
    | WooCommerce + WoodMart Core only (Table Rate deactivated) | Editor opens normally |
    | WooCommerce + Table Rate Shipping, Twenty Twenty-Five theme, editing the Cart block | Editor opens normally |

    (WoodMart Core has to stay active, since it registers the Layouts post type.)

    **Error**
    `
    Fatal error: Uncaught Error: Call to a member function get() on null
    in wp-content/plugins/woocommerce-table-rate-shipping/includes/class-wc-table-rate-shipping.php:271
    #0 class-wp-hook.php(353): WC_Table_Rate_Shipping->maybe_show_abort(”)
    #1 class-wp-hook.php(377): WP_Hook->apply_filters(”, Array)
    #2 plugin.php(523): WP_Hook->do_action(Array)
    #3 themes/woodmart/inc/integrations/gutenberg/src/layouts/woo-hook/render.php(195): do_action(‘woocommerce_bef…’)
    …
    #11 class-wp-rest-posts-controller.php: apply_filters(‘the_content’, …)
    #17 rest_preload_api_request(Array, ‘/wp/v2/woodmart…’)
    #19 wp-admin/edit-form-blocks.php(132): block_editor_rest_api_preload(…)
    `

    **Cause: two things combine**
    1. **WoodMart:** the Cart layout contains a Woo hook block set to woocommerce_before_cart. When the editor loads, WordPress preloads the layout through the REST API from wp-admin, and wd_gutenberg_woo_hook() (inc/integrations/gutenberg/src/layouts/woo-hook/render.php, around line 195) runs do_action( 'woocommerce_before_cart' ). In that admin/REST request WooCommerce hasn’t loaded a session or cart, so WC()->session is null. Normally this hook only fires from templates/cart/cart.php on the storefront, where a session always exists. That’s why a default theme with the Cart block doesn’t trigger it.
    2. **Table Rate Shipping:** maybe_show_abort() is hooked to woocommerce_before_cart (line 134) and woocommerce_before_checkout_form_cart_notices (line 135). On line 271 it calls WC()->session->get( self::$abort_key ) without checking that the session exists. WooCommerce core’s own functions on the same hook already guard against this: wc_get_notices() returns early when ! WC()->session.

    **Suggested fixes (either one prevents the crash)**
    – **WoodMart:** when the Woo hook block renders cart or checkout hooks in the editor/REST context, load the cart and session first (e.g. wc_load_cart()), or skip storefront hooks there and show a placeholder.
    – **Table Rate Shipping:** add a guard at the start of maybe_show_abort():
      `php
      if ( ! WC()->session || ! WC()->cart ) {
          return;
      }
      `

    **Steps to reproduce**
    1. Activate the WoodMart theme, WoodMart Core, WooCommerce and Table Rate Shipping 3.7.4.
    2. WoodMart → Layouts → add a Cart layout containing a Woo hook block set to woocommerce_before_cart.
    3. Save, then reopen the layout in the block editor. The fatal error appears.

    **Current workaround:** deactivate Table Rate Shipping while editing the layout, then reactivate it.

    I have attached a copy of the Table Rate Shipping plugin to this email. This is the official WooCommerce extension.

    ### Issue 2: PHP warning in woodmart_page_title() on author archives with no posts (WoodMart)

    **What happens**
    Visiting an author archive for a user with no blog posts logs:
    `
    Warning: Undefined array key 0 in wp-includes/class-wp-query.php on line 3754
    `
    Our store doesn’t use a blog. The admin user has published pages and products but no posts, and WordPress still lists /author/admin/ in its core sitemap (wp-sitemap-users-1.xml).

    **Isolation (staging site)**
    | Setup | Result |
    | WoodMart theme, WooCommerce only (all other plugins deactivated) | Warning |
    | WoodMart theme, no plugins at all | Warning |
    | Twenty Twenty-Five theme, no plugins | No warning |

    **Backtrace**
    `
    Warning: Undefined array key 0 in wp-includes/class-wp-query.php:3754
       <- wp-includes/class-wp-query.php:3813 next_post()
       <- wp-includes/query.php:1025 the_post()
       <- wp-content/themes/woodmart/inc/template-tags/template-tags.php:1702 the_post()
       <- woodmart_page_title()
       <- wp-content/themes/woodmart/inc/template-tags/template-tags.php:1079 (woodmart_page_top_part)
       <- wp-content/themes/woodmart/header.php:30
    `

    **Cause**
    In inc/template-tags/template-tags.php, the is_author() branch of woodmart_page_title() (around line 1702) calls the_post() without checking have_posts(). On an author archive with zero posts, WP_Query::next_post() reads $this->posts[0], which doesn’t exist.

    **Suggested fix**
    `php
    if ( is_author() ) {
        $author = get_queried_object();
        if ( $author instanceof WP_User ) {
            $title = esc_html__( ‘Posts by ‘, ‘woodmart’ ) . ‘<span class=”vcard”><a class=”url fn n” href=”‘ . esc_url( get_author_posts_url( $author->ID ) ) . ‘” title=”‘ . esc_attr( $author->display_name ) . ‘” rel=”me”>’ . esc_html( $author->display_name ) . ‘</a></span>’;
        }
    }
    `
    Alternatively, wrap the existing the_post() / rewind_posts() block in if ( have_posts() ) { ... }.

    #730525

    Serg Sokhatskyi
    Keymaster
    Xtemos team

    Hi there,

    Thank you for the detailed report.

    We have released patch #730522 to address these issues. Please apply it under Dashboard → WoodMart → Patcher, then test both cases again on your staging site.

    Kind regards,
    XTemos Studio

    #730527

    dtech10
    Participant

    Thank you

    #730662

    Serg Sokhatskyi
    Keymaster
    Xtemos team

    You are always welcome. Feel free to contact us if you have any further questions.

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

The topic ‘Bugs (Table Rate Shipping & author archives)’ is closed to new replies.