This shortcode evaluates if a certain (logged in) user has bought a certain (current in loop) product. The WooCommerce function seems buggy and some attention is needed. Check the code first to see if it is still working with the workaround.
functions.php:
add_shortcode('wpv-product-purchased', 'wpv_product_purchased_func'); function wpv_product_purchased_func($atts){ $current_user = wp_get_current_user(); $email = $current_user->email; return (wc_customer_bought_product( $email, $current_user->ID, get_the_ID())); }
Register this shortcode in Views > Settings:
wpv-product-purchased
Then evaluated as this:
The function of WooCommerce itself is returning a error, and the ShortCode works as expected, although it returns a numerical value “1” for bought and a empty value “” for not bought, not a boolean “true” or “false” as stated by WooCommerce.
This might be a Bug in their code or misunderstanding on my end reading the Core code of WooCommerce, and it could therefore change in future.