Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Show Woocommerce demo store notice only on tuesdays

I would like to show the woocommerce store notice demo_store only when store is closed. This is every tuesday. I thought about first getting the date, then remove the action and re-add it on tuesdays. I would love to learn how to do this.

function is_store_closed() {
    
    // weekday[0] =  "Sunday";
    // weekday[1] = "Monday";
    // weekday[2] = "Tuesday";
    // weekday[3] = "Wednesday";
    // weekday[4] = "Thursday";
    // weekday[5] = "Friday";
    // weekday[6] = "Saturday";
    
         return (date('true', strtotime($date)) == 2);
    }    
    
    function conditional_store_notice() {
        // Remove default 'woocommerce_demo_store' notice
        remove_action( 'wp_footer', 'woocommerce_demo_store' );
    
        // Add back the woocommerce_demo_store' notice, but only if tuesday
        if ( ! is_store_closed() ) {
            add_action( 'wp_footer', 'woocommerce_demo_store' );
        }
    
    }
    add_action( 'wp_footer', 'conditional_store_notice' );
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can remove that html from filter, Ideally it removes the content from rendering.

function is_store_closed() {
    $timestamp = time();
    return ( date( 'w', $timestamp ) === '2' );
}

add_filter( 'woocommerce_demo_store', function( $html, $notice ){
    if( !is_store_closed() ){
        return '';
    }

    return $html;
}, 10, 2 );

This code remove Store notice content on other days of week.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!