How to enable 'Add to Cart' only for current week's menu?

How to enable 'Add to Cart' only for current week's menu?

mughal
Visitor
1 0 0

Hi There, i am making a store for my client where his requirement is to sell food on weekly basis so there are 4 menus for 4 weeks so i created a weekly menu page and showing four products Week1, Week2, Week3 & Week4 now problem is my client wants to enable "Add to cart" button only for running week and for rest 3 weeks "Add to cart" should be disabled so buyer can see all 4 weeks menu but can add to cart only the available one for example if the date is 9th of october means add to cart button is disabled for week1, week3 and week4 but enabled for week2 .. how can i do this? please tell me the way or app or whatever is possible .. thank you

Replies 6 (6)

Reena_Soni
Shopify Partner
138 24 34

Hi @mughal,

This seems to be custom development task.

Let me know if you want to hire me

 

Regards

Reena 


Chat on WhatsApp

Need a developer? Hire me at sonireena1031@gmail.com
For Shopify Design Changes | Shopify Custom Coding | Custom Modifications Into Shopify Theme.
If I helped you out, mark it as the solution and drop me a thumbs up! | Shopify Partner | Do not hesitate to contact me via Message.
BAKHAT-ALI
Visitor
1 0 0

To enable the 'Add to Cart' feature only for the current week's menu, follow these steps  to ensure that your website or app restricts purchases to the items available for the specific week:

1. Define the Current Week's Menu

  • Create a separate menu list for each week, ensuring that it dynamically updates based on the current date.
  • Use a scheduling system or content management system (CMS) that automatically populates the menu with the appropriate items when a new week begins.

2. Restrict the 'Add to Cart' Button

  • Hide 'Add to Cart' for Non-Current Items: Implement logic that checks whether the item belongs to the current week's menu before displaying the 'Add to Cart' button. If the item is not part of the current week, hide or disable the button.
 
 
 

horacerichmond
Visitor
1 0 0

To enable the 'Add to Cart' feature only for the current week's menu, follow these steps to ensure that your website or app restricts purchases to the items available for the specific week:

1. Define the Current Week's Menu

  • Create a separate menu list for each week, ensuring that it dynamically updates based on the current date.
  • Use a scheduling system or content management system (CMS) that automatically populates the menu with the appropriate items when a new week begins.

2. Restrict the 'Add to Cart' Button

  • Hide 'Add to Cart' for Non-Current Items: Implement logic that checks whether the item belongs to the current week's menu before displaying the 'Add to Cart' button. If the item is not part of the current week, hide or disable the button.

haily22
Visitor
1 0 0

You can achieve this using a custom code snippet or a Shopify/WooCommerce plugin that enables date-based product availability. Set conditions to check the current date and enable the "Add to Cart" button only for the running week's menu while keeping others disabled.

For Shopify, apps like "Advanced Product Options" or "Dynamic Product Restrictions" can help.
For WooCommerce, use "WooCommerce Product Restrictions" or add a custom PHP function to disable the button based on the date.

This way, customers can browse all weekly menus but order only the active one—just like a fresh meal that’s available only at the right time!

Elijah_Parker
Visitor
1 0 0

 

Hey @mughal — great question, and I’ve run into a similar scenario while managing a local food ordering site inspired by the Cook Out Menu (where they rotate trays weekly).

Here’s one way you can do it if you’re using Shopify or WooCommerce:

🛒 For Shopify:

You can use Shopify’s Liquid code to compare the current date with a custom metafield or tag you've set for each week’s product. Example:

 

liquid
CopyEdit
{% assign current_week = 'Week2' %} {% if product.tags contains current_week %} <!-- Show Add to Cart Button --> {% else %} <!-- Hide or Disable Button --> {% endif %}

 

 

You can dynamically assign current_week using date logic or apps like Mechanic or Shopify Flow (for Plus users).

🧩 For WooCommerce:

Use a simple PHP snippet in your theme's functions.php:

 

php
CopyEdit
add_filter('woocommerce_is_purchasable', 'weekly_menu_control', 10, 2); function weekly_menu_control($purchasable, $product) { $current_week = 'Week2'; // Set dynamically based on current date if (has_term($current_week, 'product_tag', $product->get_id())) { return true; } return false; }
 

Just tag each product with the correct week and update $current_week based on the date.

Let your client know it’s kind of like running a rotating Cookout Tray special — the customer can see all the delicious options in the menu, but only order what’s on deck for the current week. 😄

Let me know what platform you’re using and I can share more targeted steps!

freddywilson112
Visitor
1 0 0

 

Hey, I actually had the same issue on my own food menu site where I needed to show different weekly menus but only allow purchases for the current week. Since you're using Shopify, here's a way you can handle it:

You can add a custom metafield to each product to represent its assigned week (for example, week number like 41, 42, etc.). Then in your theme’s product or collection template, use Liquid code to compare the current week number with the product’s week number.

Here’s a simple example of how the logic works:

 

 
{% assign current_week = 'now' | date: '%U' %} {% assign product_week = product.metafields.custom.week_number %} {% if current_week == product_week %} <button type="submit" class="add-to-cart">Add to Cart</button> {% else %} <button type="button" disabled style="opacity: 0.5;">Not Available This Week</button> {% endif %}
 

This checks if the product is part of the current week and shows or disables the button accordingly. You’ll just need to make sure each product has the correct week_number metafield set.

If you're not comfortable editing the code, you could also use an app like Advanced Product Options by HulkApps or Mechanic to set up rules for availability based on the current date or week.