[SOLVED] How to convert Opencart 2.2.0.0 to SSL and resolve Undefined Error while editing orders?

Opencart 2.2. to SSL

Follow these easy steps to convert your Opencart 2.2.0.0 instance from HTTP to HTTPS.

  1. Register a CloudFlare account.
  2. Add your domain with the Free plan.
  3. Change domain nameserver with the ones provided by Cloudflare
  1. Click on Crypto menu option and do the following
    a. Order SSL certificate.
    b. Set Always use HTTPS to ON.
    c. Set Require Modern TLS to ON.
    d. Set Automatic HTTPS Rewrites to ON.
  2. On the OpenCart 2.2.0.0 admin panel, browse to System / Settings / Server option and set Use SSL to Yes.
  3. On CPanel/Webmin
    • Edit .htaccess file in root folder and replace the following
    • RewriteCond %{HTTP_HOST} ^domain.com$
      RewriteRule ^/?$ "http\:\/\/www\.domain\.com" [R=301,L]
      
      with
      RewriteCond %{HTTPS_HOST} ^domain.com$
      RewriteRule ^/?$ "https\:\/\/www\.domain\.com" [R=301,L]
    • Edit config.php in public_html (root) folder and replace
    • define('HTTPS_SERVER', 'http://www.domain.com/');
      with
      define('HTTPS_SERVER', 'https://www.domain.com/');
    • Edit config.php in public_html/admin folder and replace
    • // HTTP
      define('HTTP_SERVER', 'http://www.domain.com/admin/');
      define('HTTP_CATALOG', 'http://www.domain.com/');
      // HTTPS
      define('HTTPS_SERVER', 'http://www.domain.com/admin/');
      define('HTTPS_CATALOG', 'http://www.domain.com/');
      with
      // HTTP
      define('HTTP_SERVER', 'https://www.domain.com/admin/');
      define('HTTP_CATALOG', 'https://www.domain.com/');
      // HTTPS
      define('HTTPS_SERVER', 'https://www.domain.com/admin/');
      define('HTTPS_CATALOG', 'https://www.domain.com/');
    • Edit admin.php, catalog.php, default.php, and install.php in public_html/system/config folder and replace
      $_['site_ssl'] = false;
      with
      $_['site_ssl'] = true;
    • Edit public_html/catalog/controller/common/header.php and replace
    • $server = $this->config->get('config_ssl');
      with
      $server = str_replace('http:', 'https:', $this->config->get('config_url'));
    • NOTE: Use this fix to resolve Undefined Error while editing orders in OC 2.2.0.0
      1. Go to public_html/admin/controller/sale/ folder and edit order.php
      2. Replace
      3. $data['store_url'] = $this->request->server['HTTPS'] ? str_replace("http", "https", $order_info['store_url']) : $order_info['store_url']; 
        with
        $data['store_url'] = $this->request->server['HTTPS'] ? str_replace("http", "http", $order_info['store_url']) : $order_info['store_url']; 
      4. Save the file.
      5. Go to Opencart Admin Panel select Extensions/Modification and click the Refresh button

If you found this post useful then follow and support me on

Bappi Dasgupta

#CryptoTrader #Blogger #WebDeveloper #WebAdministrator

Bappi Dasgupta

Leave a Reply

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