1. Home
  2. Docs
  3. Abandoned Cart Email
  4. Installation

Installation

This installation steps are applicable for the OpenCart versions 2.0.x.x, 2.1.x.x, 2.2.0.0, 2.3.x.x, 3.0.x.x

  • This extension requires the base plugin developed by HuntBee OpenCart Services.
  • This extension requires OCMOD Modification system.
  • No file overwritten.

Step 1

  1. Install Base plugin. If already installed, you can skip this step.

Step 2

  1. Download the package (abandoned-cart-pro-x.x.x.ocmod.zip) as per your opencart version into your local folder.
  2. Login to your website admin
  3. Navigate to Extensions > Installer
  4. Upload abandoned-cart-pro-x.x.x.ocmod.zip
  5. Navigate to Extensions > Extensions > Productivity Apps
  6. Click install button on Abandoned Cart PRO
  7. Click on edit button
  8. Make appropriate settings.
  9. Click on Save.
  10. Navigate to Extensions > Extensions >  Modifications. You should find Abandoned Cart Email in the list. Click on Refresh modification
  11. Test the extension.
  12. In case of any issue, you can uninstall the extension or disable the modification “Abandoned Cart Email” from the Extensions > Modification list and report the issue at https://www.huntbee.com/get-support 

Additional Installation Instruction for OpenCart 20xx and 21xx version

If you are using OpenCart 2.2.0.0 or any higher or latest version, do not follow the below instruction.

The following instructions are only for opencart versions 2.0.0.0, 2.0.1.0, 2.0.1.1, 2.0.2.0, 2.0.3.1, 2.1.0.1, 2.1.0.2

Open index.php of your opencart directory. Copy and paste the following PHP code at the end of the index.php , right before the $response->getOutput(); line:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//HB ABANDONED CART
 if ($config->get('hb_cart_status')) {
   $cookie_expiration_time = time() + (90 * 24 * 60 * 60);  // for 3 month
   if (!$customer->isLogged()) {
    $guest_session_id = $session->getId();

    if (!isset($request->cookie['hb_session_id'])) {
        setcookie("hb_session_id", $guest_session_id, $cookie_expiration_time, "", "", "", "true");
    }

    if (isset($session->data['guest'])){

        $cart_guest = $db->query("SELECT * FROM `".DB_PREFIX."cart_guest` WHERE session_id = '".$db->escape($guest_session_id)."' LIMIT 1");
        if ($cart_guest->num_rows > 0 ) {
            $db->query("UPDATE `".DB_PREFIX."cart_guest` SET guest_details = '".$db->escape(json_encode($session->data['guest']))."' WHERE session_id = '". $db->escape($guest_session_id) ."'");
        }else{
            $db->query("INSERT INTO `".DB_PREFIX."cart_guest` (`session_id`, `guest_details`,`store_id`) VALUES ('".$db->escape($guest_session_id)."', '".$db->escape(json_encode($session->data['guest']))."', '" . (int)$config->get('config_store_id') . "')");
        }

        if (isset($session->data['guest']['email'])) {
            setcookie("hb_email", $session->data['guest']['email'], $cookie_expiration_time, "", "", "", "true");    
        }

    }

    if (isset($request->cookie['hb_session_id'])) {
        //update hb_session_id with new session_id and copy saved carts
        $previous_cookie = $request->cookie['hb_session_id'];

        if ($session->getId() != $previous_cookie) {
            $db->query("UPDATE `".DB_PREFIX."hb_cart` SET session_id = '".$db->escape($session->getId())."' WHERE session_id = '".$db->escape($previous_cookie)."'");
            if (version_compare(VERSION,'2.1.0.0', '>')) {
                $db->query("UPDATE `".DB_PREFIX."cart` SET session_id = '".$db->escape($session->getId())."' WHERE session_id = '".$db->escape($previous_cookie)."'");
            }
            $db->query("UPDATE `".DB_PREFIX."cart_guest` SET session_id = '".$db->escape($session->getId())."', date_modified = now() WHERE session_id = '".$db->escape($previous_cookie)."'");
            setcookie("hb_session_id", $session->getId(), $cookie_expiration_time, "", "", "", "true");
        }                  

    }

    if ($config->get('hb_cart_ip_matching')) {
        if (!empty($_SERVER['HTTP_CLIENT_IP']))  {
            $ip_address = $_SERVER['HTTP_CLIENT_IP'];
        }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  {
            $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
        }else {
            $ip_address = $_SERVER['REMOTE_ADDR'];
        }

        $ip_data = $db->query("SELECT session_id FROM `".DB_PREFIX."hb_cart` WHERE ip = '".$db->escape($ip_address)."' LIMIT 1");
       
        if ($ip_data->row) {
            $ip_session_id = $ip_data->row['session_id'];
            $db->query("UPDATE `".DB_PREFIX."hb_cart` SET session_id = '".$db->escape($session->getId())."' WHERE session_id = '".$db->escape($ip_session_id)."'");
            if (version_compare(VERSION,'2.1.0.0', '>')) {
                $db->query("UPDATE `".DB_PREFIX."cart` SET session_id = '".$db->escape($session->getId())."' WHERE session_id = '".$db->escape($ip_session_id)."'");
            }
            $db->query("UPDATE `".DB_PREFIX."cart_guest` SET session_id = '".$db->escape($session->getId())."', date_modified = now() WHERE session_id = '".$db->escape($ip_session_id)."'");
            setcookie("hb_session_id", $session->getId(), $cookie_expiration_time, "", "", "", "true");                    
        }
    }

    if (isset($request->cookie['hb_email'])) {
        if (filter_var($request->cookie['hb_email'], FILTER_VALIDATE_EMAIL)) {
            $guest_email = array('email'   => $request->cookie['hb_email']);
            $cart_guest = $db->query("SELECT * FROM `".DB_PREFIX."cart_guest` WHERE session_id = '".$db->escape($guest_session_id)."' LIMIT 1");
            if ($cart_guest->num_rows == 0 ) {
                $db->query("INSERT INTO `".DB_PREFIX."cart_guest` (`session_id`, `guest_details`,`store_id`) VALUES ('".$db->escape($session->getId())."', '".$db->escape(json_encode($guest_email))."', '" . (int)$config->get('config_store_id') . "')");
            }
        }
    }
  }
}
//HB ABANDONED CART
Was this article helpful to you? Yes No