27 May 2020

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 "<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");

No comments:

Post a Comment

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...