3

Our Magento is attached to a second database which is responsible for commodities management.
Now this second database is quite strange as it developed over years and one of the strange things is that it cannot handle inserts while it's beeing backuped.

The problem is that the Shop could theoretically sell things, even thought the commodities DB is backuping.

Now what I need is to somehow disable checkouts for a certain time every night.
How could I go for it?

1
  • Did you ever get this sorted? Commented Nov 20, 2014 at 8:51

1 Answer 1

0

You can override the Mage_Checkout_Helper_Data::canOnepageCheckout method.
That one checks if you can perform a onepage checkout and add your restriction in there.

In your new class you can make it look like this:

<?php 
class [Namespace]_Checkout_Helper_Data extends Mage_Checkout_Helper_Data {
    public function canOnepageCheckout(){
        $from = '0:00';
        $to = '3:00';
        //you can make the values above come from a config setting
        $fromParts = explode(':', $from);
        $toParts = explode(':', $to);
        $nowHour = date('H');
        $nowMinutes = date('i');
        if ($nowHour > $fromParts[0] || 
           ($nowHour == $fromParts[0] && $nowMinutes >= $fromParts[1]))  && 
           ($nowHour < $toParts[0] || ($nowHour == $toParts[0] && $nowMinutes <= $toParts[1])) 
        ){ //dont allow checkout between the specified hours.
            return false;
        }

        return parent::canOnepageCheckout();
    }
}

I hope I closed all the brackets right.

You can do the same for the multishipping if you have it enabled. For multishipping the method is in the same helper and it's called isMultishippingCheckoutAvailable.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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