Hire an Agile Team for your business

Create your own agile squad with experienced members for your business.

Connect with Experts

How to put only specific Zen Cart pages down for maintenance

Last Updated on May 29, 2019 by Numinix Developer

Whenever you can, you should be using a development installation to test and make changes to your website before moving the modifications to your live store.  However, if for some reason you absolutely must work on your live store, you may want to put only the area of the website you are working on down for maintenance.

If you have used the module Fast and Easy AJAX Checkout, it is already possible to place the checkout down for maintenance while leaving the rest of your website open to the public.  But what about other pages?  It would be time consuming to place each page down individually using the same method we used in the FEAC module.  Luckily, we’ve implemented a simple method with only one core file change and one configuration setting added to the admin.

Firstly, patch your database with the following code:

INSERT INTO configuration ( `configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` ) VALUES
(NULL , 'Maintenance Pages', 'DOWN_FOR_MAINTENANCE_PAGES', '', 'Enter the define page names separated by commas without spaces (i.e. blog,checkout_shipping,checkout_payment)', '20', '99', '', now(), NULL , NULL);

Next open the file /includes/init_includes/init_customer_auth.php and find:

29
30
31
32
33
if (DOWN_FOR_MAINTENANCE == 'true') {
  if (!strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])){
    if ($_GET['main_page'] != DOWN_FOR_MAINTENANCE_FILENAME) $down_for_maint_flag = true;
  }
}

And replace it with:

if (DOWN_FOR_MAINTENANCE == 'true') {
  if (!strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])){
    if (defined('DOWN_FOR_MAINTENANCE_PAGES') && DOWN_FOR_MAINTENANCE_PAGES != '') {
      $maintenance_pages = explode(',', DOWN_FOR_MAINTENANCE_PAGES);
      if (in_array($_GET['main_page'], $maintenance_pages)) $down_for_maint_flag = true;
    } else {
      if ($_GET['main_page'] != DOWN_FOR_MAINTENANCE_FILENAME) $down_for_maint_flag = true;
    }
  }
}

Note: The site will show a down for maintenance message to the admin if an IP address is specified. For all other customers, they will see the site as usual.

One thought on “How to put only specific Zen Cart pages down for maintenance

  1. Whenever you can, you should be using a development installation to test and make changes to your website before moving the modifications to your live store.
    That’s a good habit..


Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Account Cart Search Cart Open Menu Arrow Link Arrow Chat Close Close Popup Facebook Twitter Google Plus linkedin2