Index: /changelog
===================================================================
--- /changelog	(revision 7862)
+++ /changelog	(revision 7863)
@@ -439,2 +439,3 @@
 - Bugfix: Fehlber bei der Suche nach Produktgruppen behoben
 - Bugfix: Produkttemplate fÃŒr den Warenkorbteaser lÃ€sst sich wieder Ã€ndern
+- Bugfix: Wird ein Produkt hinzugefÃŒgt fÃŒr das ein Gutschein nicht gÃŒltig ist, wird der Gutschein entfernt
Index: /mods/wpsg_mod_gutschein.class.php
===================================================================
--- /mods/wpsg_mod_gutschein.class.php	(revision 7862)
+++ /mods/wpsg_mod_gutschein.class.php	(revision 7863)
@@ -687,12 +687,13 @@
 		} // public function basket_row_end(&$basket)
 
-		public function basket_preInsert()
-		{
-
-			if (!wpsg_isSizedArray($_SESSION['wpsg']['gs'])) return;
-
-			$gs_db = $this->db->fetchRow("SELECT G.`id`, G.`productgroups`, G.`products` FROM `".WPSG_TBL_GUTSCHEIN."` AS G WHERE G.`id` = '".wpsg_q($_SESSION['wpsg']['gs']['id'])."'");
-
-			if ($gs_db['id'] != $_SESSION['wpsg']['gs']['id']) throw new \Exception(__('In der Session befindet sich eine Gutschein ID, die es nicht in der Datenbank gibt', 'wpsg'));
+		public function basket_preInsert() {
+
+			$gs_id = wpsg_getInt($_SESSION['wpsg']['gs'][0]['id']);
+
+			if (!wpsg_isSizedInt($gs_id)) return;
+
+			$gs_db = $this->db->fetchRow("SELECT G.`id`, G.`productgroups`, G.`products` FROM `".WPSG_TBL_GUTSCHEIN."` AS G WHERE G.`id` = '".wpsg_q($gs_id)."'");
+
+			if ($gs_db['id'] != $gs_id) throw new \Exception(__('In der Session befindet sich eine Gutschein ID, die es nicht in der Datenbank gibt', 'wpsg'));
 
 			$product_id = $this->shop->getProduktID($_REQUEST['wpsg']['produkt_id']);
@@ -701,6 +702,5 @@
 
 			$temp = wpsg_explode(',', $gs_db['productgroups']);
-			if (wpsg_isSizedArray($temp))
-			{
+			if (wpsg_isSizedArray($temp)) {
 
 				$ProductGroupIDs = wpsg_explode(',', $gs_db['productgroups']);
@@ -713,6 +713,5 @@
 			$product_allowed = wpsg_trim($product_allowed);
 
-			if (wpsg_isSizedArray($product_allowed) && !in_array($product_id, $product_allowed))
-			{
+			if (wpsg_isSizedArray($product_allowed) && !in_array($product_id, $product_allowed)) {
 
 				$product_data = $this->shop->loadProduktArray($product_id);
@@ -724,6 +723,5 @@
 		} // public function basket_preInsert()
 
-		public function basket_afterRemove()
-		{
+		public function basket_afterRemove() {
 
 			$arBasket = $this->shop->cache->getShopBasketArray();
@@ -733,6 +731,5 @@
 		} // public function basket_afterRemove()
 
-		public function basket_afterUpdate(&$bError)
-		{
+		public function basket_afterUpdate(&$bError) {
 
 			$this->_checkBasket($this->shop->cache->getShopBasketArray());
@@ -752,6 +749,5 @@
 		 * PrÃŒft den Basket und entfernt den Gutschein, sollte irgendetwas nicht passen
 		 */
-		private function _checkBasket($arBasket)
-		{
+		private function _checkBasket($arBasket) {
 
 			if (!wpsg_isSizedArray($arBasket['gs'])) return true;
