Skip to content


This came in from a Stack Overflow question called WooCommerce Link Product Visibility To Day Of Week

Required Plugins


  1. Copy the WooCommerce template file content-product.php to your theme’s woocommerce directory
  2. Change the area where it checks for visibility


// Ensure visibility
if ( ! $product || ! $product->is_visible() )


// Ensure visibility
// starting custom content
$product_visible = check_for_product_allowed_days( $product );
if ( ! $product || ! $product->is_visible() || ! $product_visible )
  1. Add the following to your functions.php file
// Allows for the display/non-display of products based off days allowed to be sold.
// This only works in conjunction with editing
// the woocommerce "content-product.php" template file
function check_for_product_allowed_days ( $product ) {

$product_id  =  $product->id;
$product_terms  =  get_the_terms ( $product_id, 'product_tag' );
// remove the strtolower if you capitalized your tag names
$current_day  =  strtolower ( date ( 'l' ) );

// $all_days value should be the name of the tag
// that you want to be able to be ordered on all days
$all_days  =  'all days';

foreach ( $product_terms as $tag ) {
if ( $tag->name  ==  $current_day || $tag->name  ==  $all_days ) {
  $product_is_visible  =  true;
else {
  $product_is_visible  =  false;
return $product_is_visible;

WooCommerce Admin Setup

  1. Add tags to all of your products
  • “All Days” or “all days” (just be sure to change the value of $all_days above to whatever you set it to be – monday, tuesday, wednesday)


I couldn’t find a method to break out of WooCommerce’s loop and set the product visibility before hand so a template update was necessary.


The results aren’t updated with this option, but it shows in this example that there is more products than are displayed.

Image: Display of WooCommerce product archive page showing specific days products only.


Purrly Digital LLC cannot be held responsible for the functionality of this code. Please make sure you test it on a development site before adding the code to your production website. There is no support available for this (and other) code snippet(s) posted on this website. If you’d like Purrly Digital to do custom development to help with your custom implementation please send a contact request.

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top