0

Am designing one restaurant website and their delivery time 10:00 Am to 10:00 Pm. How to make customers to placing order after the working hours. Is there any simple way?

1

You can use sales_order_place_before event to stop placing order after a specific time.

In your config (this is part of config.xml)

<config>
    <frontend>
        <events>
            <sales_order_place_before> 
                <observers>
                    <stop_placing_order>
                        <class>your_module/observer</class>
                        <method>stopOrder</method>
                    </stop_placing_order>
                </observers>
            </sales_order_place_before>
        </events>
    </frontend>
</config>

In your observer you can have this function:

public function stopOrder($observer)
{
    $order = $observer->getEvent()->getOrder();
    $address = $order->getShippingAddress();
    $postCode = $address->getPostcode();
    $currentTime = Mage::getModel('core/date')->date('Y-m-d H:i:s');


    // make your timing conditions... i just give the example of if() condition.

    if($currentTime <= 10:00:00 am || $currentTime >= 10:00:00 pm )
    {
       Mage::getSingleton('checkout/session')->addError('Store has been closed');

       Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
       Mage::app()->getResponse()->sendResponse();
       exit;
    }
}

I haven't tested but this should do the trick for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.