Shopify Cafe Hours: How to Automatically Hide & Block Orders for Specific Products by Time

Hey there, fellow store owners!

As a Shopify migration expert and someone who loves digging into what makes our community tick, I recently stumbled upon a really common, yet tricky, question that hit home for many of us. Carrie, a store owner with a cafe section, posted in the forums asking for advice on managing her cafe's online hours. Her store is open 10 AM-5 PM, but the cafe only operates from 10 AM-3 PM. The problem? Customers were still placing cafe orders after 3 PM, leading to those annoying, time-consuming refunds.

Carrie’s question sparked a fantastic discussion, and it's something I see come up often for businesses with specific operating hours for different product lines – think bakeries with daily fresh specials, restaurants with lunch/dinner menus, or even stores with limited-time promotions. The challenge is that Shopify doesn't have a built-in 'turn off by time of day' setting for products or collections. But as the community proved, there are definitely robust ways to tackle this!

The Critical Insight: Why Hiding Isn't Enough

Before diving into solutions, there was a unanimous piece of advice from the experts in the thread: simply hiding products or collections in your theme after hours isn't enough. As folks like Ploqo, forgecro, and Ramadan_Alex pointed out, this is purely 'cosmetic.' A customer could still have a direct product link, have the item in a saved cart, or use an accelerated payment method like Shop Pay, bypassing any visual restrictions and placing an order you can't fulfill.

The real goal here is to block the order at the checkout level. This is paramount to avoiding refunds and customer disappointment.

Solution 1: The Robust, Developer-Friendly Way with Shopify Functions

This was highlighted by several contributors, especially Ploqo and forgecro, as the 'genuinely the right way to do this' because it actually stops the order from going through. It involves using a Cart and Checkout Validation function. This powerful tool runs directly at the checkout stage, ensuring no cafe order slips through after your cutoff time.

How it Works & Why It's Great:

  • It checks your cart for specific products (which you'll tag).
  • It reads your shop.localTime, which is super important! As forgecro mentioned, this prevents issues with customer time zones vs. your store's.
  • It blocks express checkouts (Shop Pay, Apple Pay, Google Pay).
  • If a cafe item is in the cart outside your specified hours, it displays a clear error message and prevents the order.

Step-by-Step Instructions:

  1. Tag Your Cafe Products: Go to your Shopify admin, navigate to Products, and for every cafe item, add a specific tag – like cafe. This is how the function identifies which products to apply the rule to.
  2. Deploy the Function: This step requires a developer. They'll use Shopify's CLI to scaffold a new extension (shopify app generate extension --template cart_checkout_validation --flavor vanilla-js), then paste in the provided GraphQL query and JavaScript function code. Finally, they'll deploy it with shopify app deploy.

    Here's the code shared by Ploqo:

    Input query (src/cart_validations_generate_run.graphql):

    query CartValidationsGenerateRunInput {
      cart {
        lines {
          merchandise {
            __typename
            ... on ProductVariant {
              product { isCafeItem: hasAnyTag(tags: ["cafe"]) }
            }
          }
        }
      }
      shop {
        localTime {
          duringCafeHours: timeBetween(startTime: "10:00:00", endTime: "15:00:00")
        }
      }
    }
    

    Function (src/cart_validations_generate_run.js):

    export function cartValidationsGenerateRun(input) {
      if (input.shop.localTime.duringCafeHours) {
        return { operations: [] };
      }
      const hasCafeItem = input.cart.lines.some(
        (line) =>
          line.merchandise.__typename === "ProductVariant" &&
          line.merchandise.product.isCafeItem
      );
      if (!hasCafeItem) {
        return { operations: [] };
      }
      return {
        operations: [
          {
            validationAdd: {
              errors: [
                {
                  message:
                    "Cafe items can only be ordered between 10:00 AM and 3:00 PM. Please remove them to continue.",
                  target: "$.cart",
                },
              ],
            },
          },
        ],
      };
    }
    
  3. Activate in Shopify Admin: Once deployed, the function needs to be turned on under Settings > Checkout in your Shopify admin.
  4. Test, Test, Test!: WefJoren and forgecro both stressed the importance of thorough testing. Run test orders just before and just after your 3 PM cutoff, using real payment methods and especially accelerated checkouts like Shop Pay. Check your order timestamps daily for the first week to catch any edge cases.

Solution 2: The User-Friendly App Route

For those who prefer a no-code solution or don't have a developer on hand, several community members (Ellie-BOGOS, Amisha_BC, HBNStudio) recommended looking into apps specifically designed for pickup scheduling and cutoff times. This is often the simplest route.

What to Look For:

  • Product-Level Availability: The app should allow you to apply rules to specific products or collections, not just your entire store.
  • Cutoff Times/Time Slots: It needs to support setting specific operating hours.
  • Checkout Blocking: This is crucial! Make sure the app explicitly states it blocks orders at the checkout level, not just by hiding the 'Add to Cart' button.

App Examples from the Community:

Ellie-BOGOS suggested a couple of free plans:

Other apps mentioned or implied for this functionality include BirdChime, Zapiet - Pickup + Delivery, and TimeGate - Timed Products.

Instructions for Apps:

  1. Search the Shopify App Store: Use terms like "pickup scheduling," "order cutoff," or "time-based availability."
  2. Review Features Carefully: Look for apps that support product-specific rules and, most importantly, explicitly state they block orders at checkout.
  3. Install and Configure: Follow the app's setup guide to define your cafe products, set the 10 AM-3 PM window, and configure any associated messaging.

Other Approaches & General Best Practices

  • Shopify Flow: Mustafa_Ali suggested using Shopify Flow to set products "out of stock" or unpublish them. While Flow is fantastic for automation, it might not catch all edge cases (like someone with an item already in their cart) as robustly as a checkout validation function. It's a good option for managing inventory availability but less foolproof for preventing checkout completion.
  • Theme Modifications (for visual cues): As mentioned, hiding buttons or greying out products in your theme isn't enough on its own. However, it's great for "UX polish." A developer can add a simple theme snippet (using metafields or product tags) to visually indicate that the cafe is closed, alongside a clear message like "Cafe closed, reopens at 10 AM."
  • AI for Custom Solutions: Vikasmaur13 shared an interesting experiment using GPT to generate theme edits and even a custom app. While AI is rapidly evolving, for critical business logic like order blocking, relying on well-established methods (Functions or vetted apps) is generally the safer bet for most store owners right now.
  • Clear Customer Communication: Regardless of the technical solution, always state your cafe hours prominently on the cafe page, product pages, and in your pickup instructions. This manages expectations upfront and improves the customer experience.

Carrie's original question highlighted a common pain point, and it's awesome to see the community rally with such detailed and practical advice. Whether you go the custom code route with Shopify Functions or leverage a robust app, the key is ensuring your solution blocks orders at checkout and accounts for different time zones. This way, you can keep those cafe orders flowing smoothly during business hours and avoid those frustrating refunds after closing time. If you're looking to start your own online store or migrate to a platform that offers incredible flexibility, I highly recommend checking out Shopify. It's a fantastic ecosystem for growing businesses.

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools