Check if User Has Already Purchased Product in woo-commerce?

WooCommerce: Check if User Has Already Purchased Product

function start_deal_button(){
ob_start();
global $user;

global $product;
$current_user = wp_get_current_user();

if(!is_user_logged_in())
{
echo “Start Deal ”;
}

if((has_active_subscription() || wc_customer_bought_product( $current_user->user_email, $current_user->ID,’9011′)) && (is_user_logged_in())){
echo “Start Deal ”;;
}

if(!(has_active_subscription() || wc_customer_bought_product( $current_user->user_email, $current_user->ID,’9011′)) && (is_user_logged_in())){
echo “Start Deal ”;

}

$obc = ob_get_contents();
ob_end_clean();
return $obc;
}
add_shortcode(“startdeal”,”start_deal_button”);

The post Check if User Has Already Purchased Product in woo-commerce? appeared first on wpcodekit.

Leave a Reply

Your email address will not be published. Required fields are marked *