OpenCart

How to enable SSL connection in OpenCart

Recently, Cloudflare enable FREE SSL Certificates to all the their users. As a long Cloudflare user, I quickly enable it to my OpenCart site. There are 2 levels of SSL in OpenCart. They are

  1. Minimum SSL – Only enable during checkout.
  2. Full SSL – SSL on entire site.

Below are the guides on how to enable both level.

Step 1 – Required for both Minimum SSL and Full SSL

This step involve enabling SSL in the OpenCart Dashboard

Log into the OpenCart Dashboard and browse to

System → Settings → Click Edit Store → Click Server tab → In “Use SSL” Check “YES” in the radio button → Click “Save” Button

Step 2- Only for Minimum SSL

This step involve enabling SSL in the “config.php” file. There are 2 files need to be edited.

1. /config.php

Find this code

// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/');
define('HTTPS_IMAGE', 'http://www.example.com/image/');

Change it to

// HTTPS
define('HTTPS_SERVER', 'https://www.example.com/');
define('HTTPS_IMAGE', 'https://www.example.com/image/');

2. /admin/config.php

Find this code

// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/admin/');
define('HTTPS_CATALOG', 'http://www.example.com/');
define('HTTPS_IMAGE', 'http://www.example.com/image/');

Change it to

// HTTPS
define('HTTPS_SERVER', 'https://www.example.com/admin/');
define('HTTPS_CATALOG', 'https://www.example.com/');
define('HTTPS_IMAGE', 'https://www.example.com/image/');

 

Step 3- Only for Full SSL

This step involve enabling SSL in the “config.php” file. There are 2 files need to be edited.

1. /config.php

Find this code

// HTTP
define('HTTP_SERVER', 'http://www.example.com/');
define('HTTP_IMAGE', 'http://www.example.com/image/');
define('HTTP_ADMIN', 'http://www.example.com/admin/');

// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/');
define('HTTPS_IMAGE', 'http://www.example.com/image/');

Change it to

// HTTP
define('HTTP_SERVER', 'https://www.example.com/');
define('HTTP_IMAGE', 'https://www.example.com/image/');
define('HTTP_ADMIN', 'https://www.example.com/admin/');

// HTTPS
define('HTTPS_SERVER', 'https://www.example.com/');
define('HTTPS_IMAGE', 'https://www.example.com/image/');

2. /admin/config.php

Find this code

// HTTP
define('HTTP_SERVER', 'http://www.example.com/admin/');
define('HTTP_CATALOG', 'http://www.example.com/');
define('HTTP_IMAGE', 'http://www.example.com/image/');

// HTTPS
define('HTTPS_SERVER', 'http://www.example.com/admin/');
define('HTTPS_CATALOG', 'http://www.example.com/');
define('HTTPS_IMAGE', 'http://www.example.com/image/');

Change it to

// HTTP
define('HTTP_SERVER', 'https://www.example.com/admin/');
define('HTTP_CATALOG', 'https://www.example.com/');
define('HTTP_IMAGE', 'https://www.example.com/image/');

// HTTPS
define('HTTPS_SERVER', 'https://www.example.com/admin/');
define('HTTPS_CATALOG', 'https://www.example.com/');
define('HTTPS_IMAGE', 'https://www.example.com/image/');

 

Step 4- Only if you use Cloudflare Flexible SSL

For your domain, select CloudFlare settings domain, browse down until you see “SSL” option. From there select Flexible SSL.

You site should be running on SSL from now on.


Fix “PHP Warning: fsockopen() ” Error in Opencart in cPanel & CSF

If you are using Opencart on a VPS or dedicated server and you have cPanel/WHM with Configserver Firewall (CSF) installed, you may encounter a problem when sending email.

If you check error log, you may see the similar error.

PHP Warning: fsockopen()  [function.fsockopen'>function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) in /home/XXXX/public_html/www.example.com/system/library/mail.php on line 153

You may try the following fix.

1. Logon to WHM & browse to ConfigServer Security & Firewall page.

2. Click on “Firewall Configuration” button

3. Find “SMTP_ALLOWUSER” option.

4. In the field add your cPanel username. If the is multiple username use comma to separate.

5. Click “Change” and Restart Configserver Firewall

This guide may fix other program such as Interspire Email Marketer as well.