Home Forums Space themes support forum Fatal error review reminder & abandoned cart php files

Fatal error review reminder & abandoned cart php files

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #710991

    patrik.varga
    Participant

    Hi!

    I have 2 fatal errors in debug log, with review reminder and abandoned cart emails.
    Could you add a fix for these in Spance Dashboard Patcher?

    Bug Report for XTS Hitek Theme Developer
    Issue: PHP 8 Fatal Error in WooCommerce Email Templates

    Description: There is a TypeError occurring in the
    review-reminder.php
    and
    abandoned-cart.php
    WooCommerce email templates within the XTS Hitek theme when running on PHP 8+.

    Error Message: Uncaught TypeError: current(): Argument #1 ($array) must be of type array, false given

    Root Cause: In both templates, the image source is retrieved using the following logic:

    php
    // In review-reminder.php
    current( wp_get_attachment_image_src( $data[‘image_id’], ‘thumbnail’ ) )
    // In abandoned-cart.php
    current( wp_get_attachment_image_src( $product->get_image_id(), ‘thumbnail’ ) )
    If an image is missing or has been deleted from the media library, the WordPress function wp_get_attachment_image_src() returns a boolean false. Passing false to the current() function triggers a Fatal Error in PHP 8+, causing a 500 Internal Server Error and halting the email sending process.

    Proposed Solution: The code should verify that wp_get_attachment_image_src() returns a valid array before attempting to access its elements. If it doesn’t, it should safely fall back to the WooCommerce placeholder image.

    Example Fix:

    php
    $image_src = wc_placeholder_img_src();
    if ( ! empty( $data[‘image_id’] ) ) {
    $src_data = wp_get_attachment_image_src( $data[‘image_id’], ‘thumbnail’ );
    if ( is_array( $src_data ) && ! empty( $src_data[0] ) ) {
    $image_src = $src_data[0];
    }
    }
    And then output $image_src in the tag instead of chaining current() directly onto the function call.

    #711120

    Artem Temos
    Keymaster
    Xtemos team

    Hello,

    Thank you for the report. We will check this and fix in our next theme update.

    Kind Regards

    #715697

    patrik.varga
    Participant

    Hello! Do you know when the next Hitek Update is expected? I submitted the bug ticket a month ago, but since then there has been no patch or template update.

    #715918

    Artem Temos
    Keymaster
    Xtemos team

    Hello,

    There is no ETA for the next update. If you want, we can fix this directly on your website. To do this, please send us your admin access.

    Kind Regards

    #715944

    Artem Temos
    Keymaster
    Xtemos team

    Hello,

    We have released a new patch for this issue – 715940. Please apply and let us know if it helps.

    Kind Regards

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