Hey, is there a way to check, with Conditions in Pro, if a user has purchased a certain product or has an active subscription through WooCommerce (or otherwise)? I’m trying to display some custom content on the front end when this is the case and the ‘is/is not logged in’ condition isn’t granular enough.
I’d check that there isn’t some WooCommerce plugin for restricting page access by subscriptions and products. If you’re looking to get a little custom there’s some functions for detecting that. It’s an interesting feature for dynamic content, checking if a product was purchased.
https://woocommerce.github.io/code-reference/namespaces/default.html#function_wc_customer_bought_product
If there isn’t one you used to be able to write your own custom conditions. I’m pretty sure this still works although I haven’t tested it. The one site where I did this is still on 5.1.5 due to the search layout bug.
add_filter('cs_dynamic_content_condition', function( $result, $field, $args ){
if ($field === 'is-product-tag') {
return is_product_tag() ? 'true' : 'false';
}
return $result;
},10, 3);
1 Like
Indeed it would be!
Thanks for chiming in @urchindesign. I’ve messed around a bit but I can’t get it figured out.
1 Like