diff --git a/src/CartStorage.php b/src/CartStorage.php
index 1f39ee9..08cb6ad 100755
--- a/src/CartStorage.php
+++ b/src/CartStorage.php
@@ -26,16 +26,18 @@ class CartStorage {
   public static function insert(array $entry) {
     $return_value = NULL;
     try {
-      $return_value = db_insert(self::TABLE)
+      // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
+      // You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
+      $return_value = \Drupal::database()->insert(self::TABLE)
         ->fields($entry)
         ->execute();
     }
     catch (\Exception $e) {
-      drupal_set_message(t('db_insert failed. Message = %message, query= %query', array(
+      \Drupal::messenger()->addError(t('db_insert failed. Message = %message, query= %query', array(
         '%message' => $e->getMessage(),
         '%query' => $e->query_string,
       )
-      ), 'error');
+      ));
     }
     return $return_value;
   }
@@ -54,7 +56,9 @@ class CartStorage {
   public static function update(array $entry) {
     try {
       // db_update()...->execute() returns the number of rows updated.
-      $count = db_update(self::TABLE)
+      // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
+      // You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
+      $count = \Drupal::database()->update(self::TABLE)
         ->fields($entry)
         ->condition('uid', $entry['uid'])
         ->condition('id', $entry['id'])
@@ -62,11 +66,11 @@ class CartStorage {
         ->execute();
     }
     catch (\Exception $e) {
-      drupal_set_message(t('db_update failed. Message = %message, query= %query', array(
+      \Drupal::messenger()->addError(t('db_update failed. Message = %message, query= %query', array(
         '%message' => $e->getMessage(),
         '%query' => $e->query_string,
       )
-      ), 'error');
+      ));
     }
     return $count;
   }
@@ -81,7 +85,9 @@ class CartStorage {
    * @see db_delete()
    */
   public static function delete(array $entry) {
-    $delete = db_delete(self::TABLE);
+    // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
+    // You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
+    $delete = \Drupal::database()->delete(self::TABLE);
     if ($entry['uid']) {
       $delete->condition('uid', $entry['uid']);
     }
@@ -109,7 +115,9 @@ class CartStorage {
    */
   public static function load(array $entry = array()) {
     // Read all fields from the dbtng_example table.
-    $select = db_select(self::TABLE, 'cart');
+    // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
+    // You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
+    $select = \Drupal::database()->select(self::TABLE, 'cart');
     $select->fields('cart');
 
     // Add each field and value as a condition to this query.
diff --git a/src/Controller/CartController.php b/src/Controller/CartController.php
index eb65490..895a1a3 100755
--- a/src/Controller/CartController.php
+++ b/src/Controller/CartController.php
@@ -105,7 +105,7 @@ class CartController extends ControllerBase {
     $cart = $utility::getCart();
     if (isset($cart['cart']) && !empty($cart['cart'])) {
       $type = node_type_load("basic_cart_order");
-      $node = $this->entityManager()->getStorage('node')->create(array(
+      $node = \Drupal::service('entity_type.manager')->getStorage('node')->create(array(
         'type' => $type->id(),
       ));
 
@@ -131,7 +131,7 @@ class CartController extends ControllerBase {
    */
   public function orderCreate() {
     $type = node_type_load("basic_cart_order");
-    $node = $this->entityManager()->getStorage('node')->create(array(
+    $node = \Drupal::service('entity_type.manager')->getStorage('node')->create(array(
       'type' => $type->id(),
     ));
 
diff --git a/src/Settings.php b/src/Settings.php
index edd37e0..3987e45 100755
--- a/src/Settings.php
+++ b/src/Settings.php
@@ -37,7 +37,7 @@ class Settings {
    */
   public static  function cartUpdatedMessage() {
     $config = static::cartSettings();
-    drupal_set_message(t($config->get('cart_updated_message')));
+    \Drupal::messenger()->addStatus(t($config->get('cart_updated_message')));
   }
 
   /**
diff --git a/src/Utility.php b/src/Utility.php
index 9a0fb91..9b909b0 100755
--- a/src/Utility.php
+++ b/src/Utility.php
@@ -225,7 +225,7 @@ class Utility extends Settings {
    */
   public static function createFields($type = NULL) {
     $fields = ($type == self::FIELD_ORDERCONNECT) ? self::getFieldsConfig(self::FIELD_ORDERCONNECT) : self::getFieldsConfig();
-    $view_modes = \Drupal::entityManager()->getViewModes('node');
+    $view_modes = \Drupal::service('entity_display.repository')->getViewModes('node');
     $storage = \Drupal::entityTypeManager()->getStorage('entity_view_display');
 
     foreach ($fields->fields as $field_name => $config) {
@@ -272,14 +272,14 @@ class Utility extends Settings {
         else {
           FieldConfig::create($config_array)->save();
           if ($config['widget']) {
-            entity_get_form_display($config['entity_type'], $bundle, 'default')
+            \Drupal::service('entity_display.repository')->getFormDisplay($config['entity_type'], $bundle, 'default')
               ->setComponent($field_name, $config['widget'])
               ->save();
           }
           if ($config['formatter']) {
             foreach ($config['formatter'] as $view => $formatter) {
               if (isset($view_modes[$view]) || $view == "default") {
-                $formatter_view = entity_get_display($config['entity_type'], $bundle, $view);
+                $formatter_view = \Drupal::service('entity_display.repository')->getViewDisplay($config['entity_type'], $bundle, $view);
                 if ($view != 'basic_cart_order') {
                   $formatter_view->setComponent($field_name, !is_array($formatter) ? $config['formatter']['default'] : $config['formatter']['default']);
                 }
@@ -300,7 +300,7 @@ class Utility extends Settings {
       // price feild in formatter and remove other fields.
       $view_display = $storage->load($config['entity_type'] . '.' . $bundle . '.basic_cart_order');
       if ($view_display != NULL) {
-        foreach (\Drupal::entityManager()->getFieldDefinitions($config['entity_type'], $bundle) as $field_name => $field_definition) {
+        foreach (\Drupal::service('entity_field.manager')->getFieldDefinitions($config['entity_type'], $bundle) as $field_name => $field_definition) {
           if (!empty($field_definition->getTargetBundle())) {
             if (!in_array($field_definition->getName(), ['add_to_cart_price'])) {
               $view_display->removeComponent($field_definition->getName());
