Hi can anyone please help.
I'm no computer buff and need a step-by-step guide if possible.
In getting this error on my product pages:
Warning: Undefined variable $post_id in /customers/5/f/d/haveitpersonalised.com/httpd.www/wp-content/plugins/extra-product-addons-for-woocommerce/App/Helpers/FieldsFromCategoryPosts.php on line 47
this is the PHP-file:
if (!defined('ABSPATH')) exit; // Exit if accessed directly
class FieldsFromCategoryPosts{
public static function getFieldsFromCategoryPosts($category_id, &$post_found_ids, $exclude_id = null){
$post_type = EPAFW_POST_TYPE;
$fields_json = [];
$args = array(
'post_type' => $post_type,
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $category_id,
),
),
);
$posts_with_category = get_posts($args);
if (!empty($posts_with_category)) {
foreach ($posts_with_category as $post) {
$post_id = $post->ID;
// Check if the post ID has already been processed.
if (!in_array($post_id, $post_found_ids)) {
if (get_post_status($post_id) == 'publish' && ($exclude_id === null || $post_id !== $exclude_id)) {
$fields_json[] = json_decode(get_post_meta($post_id, EPAFW_FORM_META_KEY, true));
}
// Append the post ID to the array to mark it as processed.
$post_found_ids[] = $post_id;
}
}
}
// echo "<pre>";
// var_dump($post_id);
// echo "</pre>";
$fields = array_merge(...$fields_json);
return array(
'post_id' => $post_id,
'fields' => $fields,
Any help much appreciated Thank you