Index: /changelog
===================================================================
--- /changelog	(revision 7645)
+++ /changelog	(revision 7646)
@@ -325,3 +325,4 @@
 - Bugfix: Auswahl der Zahl- und Versandarten im Produkt funktioniert zuverlÃ€ssig (PayPal Plus + Zahlvariante) / Task #708
 - Bugfix: Speichern von Rabatt % Werten in Kundengruppen/Produktgruppen und Produkten korrigiert
+- Feature: Zahlungsart "Kostenfrei" fÃŒr Bestellungen die mit 0,- durchgefÃŒhrt werden / Task  #709
 - Technisch: Ausgabe Overview wird zwischengespeichert, um Performance zu erhÃ¶hen
Index: /controller/wpsg_ShopController.class.php
===================================================================
--- /controller/wpsg_ShopController.class.php	(revision 7645)
+++ /controller/wpsg_ShopController.class.php	(revision 7646)
@@ -3173,14 +3173,17 @@
 		 */
 		public function addShipPay() {
-
-			//if ($this->arShipping === null && $this->arPayment === null) { 
+ 
+			$this->arPayment = [
+				0 => [
+					'name' => __('Kostenlos', 'wpsg'),
+					'id' => '0'
+				]
+			];
 			
-				$this->callMods('addShipping', array(&$this->arShipping));
-				$this->callMods('addPayment', array(&$this->arPayment));
+			$this->callMods('addShipping', array(&$this->arShipping));
+			$this->callMods('addPayment', array(&$this->arPayment));
 	
-				$this->callMods('addShipping', array(&$this->arShippingAll, true));
-				
-			//}
-            
+			$this->callMods('addShipping', array(&$this->arShippingAll, true));
+			            
 		} // public function addShipPay()
 
@@ -4475,7 +4478,6 @@
 		 * ÃberprÃŒft die vorhandenen Versandarten und entfernt Versandarten die im Warenkorb nicht erlaubt sind
 		 */
-		public function checkShippingAvailable()
-		{
-
+		public function checkShippingAvailable() {
+ 
 			$arShippingNew = array();
 
@@ -4649,43 +4651,57 @@
 		 * ÃberprÃŒft die vorhandenen Zahlungsarten und entfernt Zahlungsarten die im Warenkorb nicht elaubt sind
 		 */
-		public function checkPaymentAvailable()
-		{
-
-			if (wpsg_isSizedArray($this->view['basket']['produkte']))
-			{
-
-				foreach ($this->view['basket']['produkte'] as $basket_product)
-				{
-
-					$oProduct = $this->cache->loadProductObject($this->getProduktID($basket_product['id']));
-
-					if ($oProduct->hasLimitedPayment())
-					{
-
-						$arPaymentAllowed = $oProduct->getAllowedPayment();
-
-						foreach ($this->arPayment as $payment_key => $payment)
-						{
-
-							if (!in_array($payment['id'], $arPaymentAllowed))
-							{
-
-								unset($this->arPayment[$payment_key]);
-
+		public function checkPaymentAvailable() {
+
+			$sum_basket = \wpsg\wpsg_calculation::getSessionCalculation()->getSum(WPSG_NETTO);
+			 
+			if ($sum_basket <= 0) {
+				
+				// Neue ab 13.01.2020
+				// Wenn <= 0 Euro, wird kostenlos als Zahlungsart verwendet
+				// Alle anderen Zahlungsarten fallen raus
+				
+				foreach ($this->arPayment as $k => $v) {
+					
+					if ($k !== 0) unset($this->arPayment[$k]);
+					
+				}
+				
+			} else {
+			
+				unset($this->arPayment[0]);
+				
+				if (wpsg_isSizedArray($this->view['basket']['produkte'])) {
+	
+					foreach ($this->view['basket']['produkte'] as $basket_product) {
+	
+						$oProduct = $this->cache->loadProductObject($this->getProduktID($basket_product['id']));
+	
+						if ($oProduct->hasLimitedPayment()) {
+	
+							$arPaymentAllowed = $oProduct->getAllowedPayment();
+	
+							foreach ($this->arPayment as $payment_key => $payment) {
+	
+								if (!in_array($payment['id'], $arPaymentAllowed)) {
+	
+									unset($this->arPayment[$payment_key]);
+	
+								}
+	
 							}
-
+	
 						}
-
+	
 					}
-
-				}
-
-			}
-
-			// UnschÃ¶ne Warnungen verhindern, sollte hier der Array null sein
-			if (!wpsg_isSizedArray($this->arPayment)) $this->arPayment = array();
-
-			$this->callMods('checkPaymentAvailable', array(&$this->arPayment, &$this->view['basket']));
-
+	
+				}
+	
+				// UnschÃ¶ne Warnungen verhindern, sollte hier der Array null sein
+				if (!wpsg_isSizedArray($this->arPayment)) $this->arPayment = array();
+	
+				$this->callMods('checkPaymentAvailable', array(&$this->arPayment, &$this->view['basket']));
+
+			}
+				
 		} // public function checkPaymentAvailable()
 
Index: /lib/wpsg_basket.class.php
===================================================================
--- /lib/wpsg_basket.class.php	(revision 7645)
+++ /lib/wpsg_basket.class.php	(revision 7646)
@@ -1173,4 +1173,5 @@
 				
 				$this->shop->checkShippingAvailable();
+				$this->shop->checkPaymentAvailable();
 				
 				// Versandart prÃŒfen
Index: /lib/wpsg_calculation.class.php
===================================================================
--- /lib/wpsg_calculation.class.php	(revision 7645)
+++ /lib/wpsg_calculation.class.php	(revision 7646)
@@ -36,4 +36,6 @@
     	private $tax_mode = '2';
 	
+    	private static $functionscache = [];
+    	
 		const TAXMODE_SMALLBUSINESS = '1';
     	const TAXMODE_B2C = '2';
@@ -385,6 +387,4 @@
         public function getCalculationArray($force_rebuild = false) {
 
-        	//die(wpsg_debug($_SESSION));
-        	
             if ($this->arCountry === null) throw new \Exception(__('Warenkorb kann nicht ohne ein gesetztes Land berechnet werden.', 'wpsg'));
             
@@ -1457,5 +1457,14 @@
 		
 		}
-	
+
+		public function getSum($bruttonetto = WPSG_NETTO) {
+			
+			$arCalculation = $this->getCalculationArray();
+			
+			if ($bruttonetto === WPSG_BRUTTO) return $arCalculation['sum']['brutto'];
+			else return $arCalculation['sum']['netto'];
+			
+		}
+		
 		private function addTax($tax_key) {
 	
@@ -1474,5 +1483,5 @@
             
         }
-
+                
         /* Static */
 	
@@ -1481,10 +1490,18 @@
 		 */
 		public static function getSessionCalculation() {
-	
-			$oCalculation = new wpsg_calculation();
-			$oCalculation->fromSession();
-			
-			return $oCalculation;
-			
+			
+			$cache_key = __FUNCTION__.implode('|', \func_get_args());
+			
+			if (!isset(self::$functionscache[$cache_key])) {
+			
+				$oCalculation = new wpsg_calculation();
+				$oCalculation->fromSession();
+				
+				self::$functionscache[$cache_key] = $oCalculation;
+				
+			}
+			
+			return self::$functionscache[$cache_key];
+				
 		}
 	        
