diff --git a/uc_order/src/Entity/OrderStatus.php b/uc_order/src/Entity/OrderStatus.php
index 8d5faa2..042e7fa 100644
--- a/uc_order/src/Entity/OrderStatus.php
+++ b/uc_order/src/Entity/OrderStatus.php
@@ -90,6 +90,10 @@ class OrderStatus extends ConfigEntityBase implements OrderStatusInterface {
    * {@inheritdoc}
    */
   public function setState($state) {
+    if ($this->isLocked()) {
+      throw new \LogicException('Locked statuses cannot be modified.');
+    }
+
     $this->state = $state;
     return $this;
   }
@@ -127,6 +131,17 @@ class OrderStatus extends ConfigEntityBase implements OrderStatusInterface {
   /**
    * {@inheritdoc}
    */
+  public function delete() {
+    if ($this->isLocked()) {
+      throw new \LogicException('Locked statuses cannot be deleted.');
+    }
+
+    parent::delete();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public static function postLoad(EntityStorageInterface $storage, array &$entities) {
     parent::postLoad($storage, $entities);
     uasort($entities, 'static::sort');
diff --git a/uc_order/src/Form/OrderWorkflowForm.php b/uc_order/src/Form/OrderWorkflowForm.php
index 46b174e..1628697 100644
--- a/uc_order/src/Form/OrderWorkflowForm.php
+++ b/uc_order/src/Form/OrderWorkflowForm.php
@@ -9,6 +9,7 @@ namespace Drupal\uc_order\Form;
 
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\uc_order\Entity\OrderStatus;
 
 /**
  * Displays the order workflow form for order state and status customization.
@@ -36,7 +37,7 @@ class OrderWorkflowForm extends ConfigFormBase {
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
     $states = uc_order_state_options_list();
-    $statuses = \Drupal\uc_order\Entity\OrderStatus::loadMultiple();
+    $statuses = OrderStatus::loadMultiple();
 
     $form['order_states'] = array(
       '#type' => 'details',
@@ -84,8 +85,6 @@ class OrderWorkflowForm extends ConfigFormBase {
     );
 
     foreach ($statuses as $status) {
-      $form['#locked'][$status->id()] = $status->isLocked();
-
       $form['order_statuses']['order_statuses'][$status->id()]['id'] = array(
         '#markup' => $status->id(),
       );
@@ -131,8 +130,8 @@ class OrderWorkflowForm extends ConfigFormBase {
     $config->save();
 
     foreach ($form_state->getValue('order_statuses') as $id => $value) {
-      $status = \Drupal\uc_order\Entity\OrderStatus::load($id);
-      if (!$form['#locked'][$id] && $value['remove']) {
+      $status = OrderStatus::load($id);
+      if (!empty($value['remove'])) {
         $status->delete();
         drupal_set_message(t('Order status %status removed.', ['%status' => $status->getName()]));
       }
@@ -141,7 +140,7 @@ class OrderWorkflowForm extends ConfigFormBase {
         $status->setWeight((int) $value['weight']);
 
         // The state cannot be changed if the status is locked.
-        if (!$form['#locked'][$key]) {
+        if (!$status->isLocked()) {
           $status->setState($value['state']);
         }
 
diff --git a/uc_order/src/Tests/OrderTest.php b/uc_order/src/Tests/OrderTest.php
index 18a0b4c..f230fec 100644
--- a/uc_order/src/Tests/OrderTest.php
+++ b/uc_order/src/Tests/OrderTest.php
@@ -224,6 +224,10 @@ class OrderTest extends UbercartTestBase {
     $this->drupalPostForm('admin/store/orders/' . $order->id(), array('status' => $edit['id']), 'Update');
     $this->drupalGet('admin/store/orders/view');
     $this->assertText($edit['name'], 'Order displays custom status title.');
+
+    // Delete the custom order status.
+    $this->drupalPostForm('admin/store/settings/orders', ['order_statuses[' . $edit['id'] . '][remove]' => 1], 'Save configuration');
+    $this->assertNoText($edit['id'], 'Deleted status ID not found.');
   }
 
   protected function ucCreateOrder($customer) {
