diff --git a/modules/store/src/SelectStoreTrait.php b/modules/store/src/SelectStoreTrait.php
index 750f5c32f4a94476d9af58604b320841513dfc39..f7014ffa8349e70161eb56d22a6c65ab36d26002 100644
--- a/modules/store/src/SelectStoreTrait.php
+++ b/modules/store/src/SelectStoreTrait.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\commerce_store;
 
+use Drupal\commerce\EntityHelper;
 use Drupal\commerce\PurchasableEntityInterface;
 
 /**
@@ -43,7 +44,8 @@ trait SelectStoreTrait {
     }
     else {
       $store = $this->currentStore->getStore();
-      if (!in_array($store, $stores)) {
+      $store_ids = EntityHelper::extractIds($stores);
+      if (!in_array($store->id(), $store_ids, TRUE)) {
         // Indicates that the site listings are not filtered properly.
         throw new \Exception("The given entity can't be purchased from the current store.");
       }