Check if Logged In User Has Already Purchased a Product
-
Hi
Please help me
i tried this code and it works on shop page,
How do I change the code for notification only on the checkout page, before the customer continues payment?add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_user_logged_in_product_already_bought', 30 ); function bbloomer_user_logged_in_product_already_bought() { global $product; if ( ! is_user_logged_in() ) return; $current_user = wp_get_current_user(); if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product->get_id() ) ) echo '<div class="user-bought">♥ Hey ' . $current_user->first_name . ', you\'ve purchased this in the past. Buy again?</div>'; }
Thank you
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Check if Logged In User Has Already Purchased a Product’ is closed to new replies.