• hello,

    i have 2 divs, i want to keep showing the div1 if the start date (acf date picker) is still true, and hide it if the end date picker is true and display div2. but this will only happen if they bought the products from woocommerce. here is what i got right now but its not working. im not sure if the IF statement is correct. screenshot https://prnt.sc/lgxdLHamnvp0

    add_action( 'woocommerce_before_single_product', 'lws3_user_logged_in_product_already_bought', 30 );
      
    function lws3_user_logged_in_product_already_bought() {
       global $product;
       if ( ! is_user_logged_in() ) return;
       if ( wc_customer_bought_product( '', get_current_user_id(), $product->get_id() ) ) {
          echo '<div>You purchased this in the past.</div>';
    	   
    	   	//start test
    	   $startdate = get_field('live_stream_start_date', false, false);
    	   $enddate = get_field('live_stream_end_date', false, false);
    		// use the same date format for the current date
    		$currentDateTime = date('Ymd');
    	//end test
    	//start test
    		if(strtotime($currentDateTime) >= strtotime($startdate) ) {
    			echo '<style>
    				.wpstream_player_wrapper {
    				display:block;
    			}
    			</style>';
    			echo 'live show';
    		} elseif (strtotime($currentDateTime) <= strtotime($enddate) ){
    			echo '<style>
    				.wpstream_player_wrapper {
    				display:none;
    			}
    			.recorded-video{
    			display:block;
    			}
    			</style>';
    			echo 'recorded show';
    		}
    	   //end test
       }
    }

    Thank you

    • This topic was modified 2 years, 2 months ago by adcadesigns.
    • This topic was modified 2 years, 2 months ago by adcadesigns.
  • The topic ‘toggle divs based on date picker start and end date’ is closed to new replies.