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
Hi, Thanks for reporting this bug.
It’s fixed in the latest release 2.7.
Regards