• Skip to main content
  • Skip to footer

W3 Plus Solutions

Web Design - SEO - eCommerce | Pickering Ontario

  • Home
  • About us
  • Our work
  • Our services
  • Blog
  • Contact us

rashid / May 31, 2018

How do you display a different widget for each day of the week?

I recently came across a question posted to the Advanced WooCommerce group on Facebook that asked

One of my clients (in a food business) is looking to promote ‘Meal of the Day’. So, for instance, he wants Meal 1 to be promoted on Monday, Meal 2 on Tuesday, Meal 3 on Wednesday, Meal 4 on Thursday and Meal 5 on Friday.

And these are not to be expired anytime. Only, deal price may change or some description.

Do we have any plugin that checks the day of the week and then present the meal in the form of banner or post?

This is an interesting question and a website feature that I think a lot of restaurant owners would appreciate. There are a lot of different ways to achieve this and the best approach will depend on the details of exactly how you want to display it deals.

Here’s how I would do it in the form of displaying the deals in a default widget area of the theme.

Assumptions:

  1. WooCommerce is installed
  2. Client will be managing the deals in the form of WooCommerce products.

Let’s get building:

1. Install and activate the Widget Logic Plugin

This is one my favourite plugins. It’s not as user friendly for clients, but it gives developers a easy way to take control of how the widgets on a site is displayed. Installation instructions can be found on the plugin page.

2. Create your product categories.

I suggest creating product categories in the following way:

  • Daily Deals
    • Monday
    • Tuesday
    • Wednesday
    • Thursday
    • Friday
    • Saturday
    • Sunday

Why the parent category of Daily Deals? This is so that you can create an additional page on your site where you can display all the daily deals. Also, helps keeps things organized in the backend.

3. Create your widgets

Use the Text Widget and the WooCommerce [products] shortcode to display the product for each day in a widget of its own. The [products] shortcode comes with lots of attributes that you can use to control how it’s displayed. For our purposes, the attribute we need is “category“.

To control the visibility of our widgets, we will add the below code in the widget logic section of the widget:

date("D") == "Mon"

Here’s an example for the Monday Widget

As you can see used the category field and set it to display only products in the category “monday” and the PHP code checks if today’s date is equal to Monday.

Repeat this for all the days you offer deals making sure you change the category slug in the products shortcode and the Day in the PHP check. In my case, I’ve created one for each day (Monday – Friday).

4. Create your products

Now, you simply need to create the deals through the regular WooCommerce product creation. Make sure to add a nice featured image and also make sure you select the right category.

Final Product on Twenty Sixteen Theme

That’s how it’ll display on Twenty Sixteen default sidebar. You can customize the number of products (deals) to display and also the look of the deal.

You can also use this technique to display posters, announcements, etc.

Filed Under: Blog, Tutorials

Contact Us

Let's Talk

Reader Interactions

Footer

Let’s Talk

Free Consultation
Contact Us
Call us toll free:
1-866-786-1333

About Us

Working from the lovely city of Toronto, Canada, we’re a team of strategists, designers and developers who love helping small-medium sized businesses navigate and succeed on the World Wide Web.

Follow us

  • View w3plus’s profile on Facebook
  • View wearew3plus’s profile on Twitter
  • View w3-plus-solutions’s profile on LinkedIn

Login

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

© 2021 · W3 Plus Solutions · Proudly built with WordPress · Affiliate Links Disclosure