• Resolved Danny

    (@daining1298)


    I go the following error

    2025-05-12T08:23:18+00:00 Critical Uncaught Error: Call to a member function get_meta() on bool in /home/public_html/wp-content/plugins/product-expiry-for-woocommerce/product-expiry-for-woocommerce.php:526

Viewing 2 replies - 1 through 2 (of 2 total)
  • antonzlo

    (@antonzlo)

    The fix is to check if the product is existing.
    You can edit the plugin file to look like this:

    function display_expiry_date() {
    $default = array(
    'single_hook' => '',
    'archive_hook' => '',
    'date_format' => get_option('date_format'),
    'notify_emails' => '',
    'display' => 'enable',
    'markup' => __('Expiry Date: %date%', 'product-expiry-for-woocommerce'),
    );

    $savedSettings = get_option('woope_admin_settings', $default);

    if ($savedSettings['display'] == 'enable') {
    $product = wc_get_product();

    // Check if $product is valid
    if (!$product) {
    return; // Exit the function if not a valid product
    }


    $expiryDate = $product->get_meta('woo_expiry_date');
    $expiryNote = $product->get_meta('woo_expiry_note');

    if ($expiryNote != '') {
    echo '<p class="woope-notice">' . esc_html($expiryNote) . '</p>';
    } elseif ($expiryDate != '') {
    $dateFormat = $savedSettings['date_format'];
    $formattedDate = date($dateFormat, strtotime($expiryDate));
    $text = str_replace("%date%", $formattedDate, $savedSettings['markup']);
    $text = apply_filters('wpml_translate_single_string', $text, 'product-expiry-for-woocommerce', 'date-markup');
    echo '<p class="woope-notice">' . esc_html($text) . '</p>';
    }

    if ($product->is_type('variable')) {
    echo '<p class="woope-variable-notice"></p>';
    }
    }
    }

    • This reply was modified 1 year ago by antonzlo.
    • This reply was modified 1 year ago by antonzlo.
    • This reply was modified 1 year ago by antonzlo. Reason: inline code block
    Plugin Author webcodingplace

    (@webcodingplace)

    Hi, Thanks for reporting this bug.

    It’s fixed in the latest release 2.7.

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Critical error from the plugin’ is closed to new replies.