Tags/topics: 
2
Answers
Vote up!
0
Vote down!

Store Opening Hours

Hi,
I've created a Take Away Store,
but one requirement is to not have users purchase items during certain "closed hours"

I'm assuming its something along the lines of a rule in the checkout settings but that's as far as I can work out currently.

Thanks for any advice !!!

Asked by: brett1
on October 26, 2013

2 Answers

Vote up!
0
Vote down!

Hello Brett1

I don't know the exact rule since I am on the road, but this can be done by setting up a Rule that does the following:

Event: Viewing Product
Condition: Data Comparison against site:current-date (I don't think you can set up both open and close in a single condition so you will also want to include another one of these)
Action: Set Data Value -> Product:Status -> 0

Travis
Answer by: Travis
Posted: Oct 28, 2013
Vote up!
0
Vote down!

I needed to do this for a site I am trying to finish, so I was able to get the actual rule setup so here it is.

{ "rules_store_hours" : {
    "LABEL" : "Store Hours",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_cart" ],
    "ON" : { "commerce_cart_product_add" : [  ] },
    "IF" : [
      { "data_is" : { "data" : [ "site:current-date" ], "op" : "\u003E", "value" : "21:00:00" } },
      { "data_is" : {
          "data" : [ "site:current-date" ],
          "op" : "\u003C",
          "value" : "09:00:00"
        }
      }
    ],
    "DO" : [
      { "drupal_message" : {
          "message" : "We\u0027re sorry but we are currently closed, your item has been removed from the cart. Online ordering has been disabled until 9:00 tomorrow morning.",
          "type" : "warning"
        }
      },
      { "commerce_cart_empty" : { "commerce_order" : [ "site:current-cart-order" ] } }
    ]
  }
}
Travis
Answer by: Travis
Posted: Nov 11, 2013