• Hello,

    I am trying to work out how to hide a class and when a logged in user has an active subscription with a variation.

    So far I have the below function which i’m trying to use.

    function has_woocommerce_subscription($the_user_id, $the_product_id, $the_status) {
    	$current_user = wp_get_current_user();
    	if (empty($the_user_id)) {
    		$the_user_id = $current_user->ID;
    	}
    	if (WC_Subscriptions_Manager::user_has_subscription( $the_user_id, $the_product_id, $the_status)) {
    		return true;
    	}
    }

    I then have another snippet code

    if (has_woocommerce_subscription('','5463','active')) {
        ?>
    <style>
      .hrfull {background: display: inherit !important;}
      .hrfree {display: none !important;}
    </style>
    <?php
    }

    I am not having any luck. Any help would be great here.

    Thank you,

    Dv

Viewing 2 replies - 1 through 2 (of 2 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    This isn’t a valid CSS rule:

    
    background: display: inherit !important;
    

    The syntax of CSS is:

    
    .hffull {
        background-color: pink;
        display: block;
    }
    

    Also you don’t need !important tags.

    Thread Starter David

    (@david2019)

    Hi Andrew,

    Thanks, that was a copy paste issue. I have fixed that up but it has not resolved the issue. Where i believe the code is breaking down is trying to detect the correct woocommerce subscription variation. So basically, if a customer has Product A, and 1 Day variation i want to show one container, and hide another.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide Class Based on User’s Subscription with variation’ is closed to new replies.