I know there is another question similar, but my problem look strange. I am running a PHP script, and keep getting errors like:
Notice: Undefined variable: product_id in D:\ MY-WEBSERVER\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\MYTHEME\functions.php on line 580
Line 580 looks like this:
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) echo '<div class="user-bought">♥ Hey ' . $current_user->first_name . ', you\'ve purchased this in the past. Buy again?</div>';
Here full code:
add_action ( 'woocommerce_after_shop_loop_item',
'user_logged_in_product_already_bought', 30);
function user_logged_in_product_already_bought() {
if ( is_user_logged_in() ) {
global $product;
$current_user = wp_get_current_user();
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) echo '<div class="user-bought">♥ Hey ' . $current_user->first_name . ', you\'ve purchased this in the past. Buy again?
</div>';
}
}
?>
Is there a quick fix to resolve these notify? Really appreciate for any help
Thank you