Check If User bought product
Check If User bought product
// Add Shortcode
function product_check( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'prd_id' => '',
), $atts )
);
// Code
$current_user = wp_get_current_user();
$email = $current_user->email;
if ( !wc_customer_bought_product( $email, $current_user->ID, $prd_id ) {
echo 'You do not have access';
}
}
add_shortcode( 'chck_user', 'product_check' );