Store Vacation Mode
Pauses all purchasing between two dates and shows a store-wide notice explaining when you will be back, while the catalog stays online.
Opens WPIDE on
Code
$wpide_vacation = array(
'start' => '2026-12-23', // First day closed (YYYY-MM-DD).
'end' => '2027-01-02', // Last day closed.
'message' => 'We are on a short break. Orders placed now will ship after January 3.',
);
$wpide_on_vacation = function () use ( $wpide_vacation ) {
$today = wp_date( 'Y-m-d' );
return $today >= $wpide_vacation['start'] && $today <= $wpide_vacation['end'];
};
add_filter( 'woocommerce_is_purchasable', function ( $purchasable ) use ( $wpide_on_vacation ) {
return $wpide_on_vacation() ? false : $purchasable;
}, 99 );
add_filter( 'woocommerce_variation_is_purchasable', function ( $purchasable ) use ( $wpide_on_vacation ) {
return $wpide_on_vacation() ? false : $purchasable;
}, 99 );
add_action( 'wp_body_open', function () use ( $wpide_on_vacation, $wpide_vacation ) {
if ( $wpide_on_vacation() ) {
echo '<div class="wpide-vacation-notice" style="padding:10px 16px;background:#fcf9e8;border-bottom:1px solid #dba617;text-align:center;">' . esc_html( $wpide_vacation['message'] ) . '</div>';
}
} );
Notes
Dates use the site timezone. Purchasing resumes automatically after $end.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.