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 "<a href='".site_url().'/my-account'."' class='start-deal-button'>Start Deal <i class='fa fa-handshake'></i></a>";
}
if((has_active_subscription() || wc_customer_bought_product( $current_user->user_email, $current_user->ID,'9011')) && (is_user_logged_in())){
echo "<a href='".site_url().'/start-deal'."' class='start-deal-button'>Start Deal <i class='fa fa-handshake'></i></a>";;
}
if(!(has_active_subscription() || wc_customer_bought_product( $current_user->user_email, $current_user->ID,'9011')) && (is_user_logged_in())){
echo "<a href='".site_url().'/pricing/'."' class='start-deal-button'>Start Deal <i class='fa fa-handshake'></i></a>";
}
$obc = ob_get_contents();
ob_end_clean();
return $obc;
}
add_shortcode("startdeal","start_deal_button");
Comments
Post a Comment