From 8fce5f2b1ffe2770593ca67a469f689bf2aa66a9 Mon Sep 17 00:00:00 2001 From: Snowy Cat Software Date: Mon, 22 Oct 2018 11:28:41 +0200 Subject: [PATCH] Fix method config --- mollie.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mollie.php b/mollie.php index 050f7438e..09bd9d5f0 100644 --- a/mollie.php +++ b/mollie.php @@ -1828,10 +1828,10 @@ public function hookDisplayAdminOrder($params) } $this->context->smarty->assign(array( - 'ajaxEndpoint' => $this->context->link->getAdminLink('AdminModules', true).'&configure=mollie&ajax=1&action=MollieOrderInfo', - 'transactionId' => $transaction['transaction_id'], - 'currencies' => $currencies, - 'tracking' => static::getShipmentInformation($params['id_order']), + 'ajaxEndpoint' => $this->context->link->getAdminLink('AdminModules', true).'&configure=mollie&ajax=1&action=MollieOrderInfo', + 'transactionId' => $transaction['transaction_id'], + 'currencies' => $currencies, + 'tracking' => static::getShipmentInformation($params['id_order']), )); return $this->display(__FILE__, 'order_info.tpl'); @@ -2375,7 +2375,7 @@ public static function getPaymentData( // Send webshop locale if ((static::selectedApi() === static::MOLLIE_PAYMENTS_API - && Configuration::get(static::MOLLIE_PAYMENTSCREEN_LOCALE) === static::PAYMENTSCREEN_LOCALE_SEND_WEBSITE_LOCALE) + && Configuration::get(static::MOLLIE_PAYMENTSCREEN_LOCALE) === static::PAYMENTSCREEN_LOCALE_SEND_WEBSITE_LOCALE) || static::selectedApi() === static::MOLLIE_ORDERS_API ) { $locale = static::getWebshopLocale(); @@ -2938,6 +2938,13 @@ protected function getMethodsForConfig($active = false) } $dbMethods = @json_decode(Configuration::get(static::METHODS_CONFIG), true); + $keys = array('id', 'name', 'enabled', 'image', 'issuers', 'position'); + foreach ($dbMethods as $index => $dbMethod) { + if (count(array_intersect($keys, array_keys($dbMethod))) !== count($keys)) { + unset($dbMethods[$index]); + } + } + if (!is_array($dbMethods)) { $dbMethods = array(); $configMethods = array(); @@ -2952,7 +2959,7 @@ protected function getMethodsForConfig($active = false) $methods = array(); $deferredMethods = array(); foreach ($apiMethods as $apiMethod) { - if (!in_array($apiMethod->id, $methodsFromDb)) { + if (!in_array($apiMethod->id, $methodsFromDb) || !isset($configMethods[$apiMethod->id]['position'])) { $deferredMethods[] = array( 'id' => $apiMethod->id, 'name' => $apiMethod->description, @@ -4861,7 +4868,7 @@ public function displayAjaxMollieMethodConfig() foreach ($methodsForConfig as $methodForConfig) { if ($dbMethod['id'] === $methodForConfig['id']) { $found = true; - foreach (array('issuers', 'image', 'name') as $prop) { + foreach (array('issuers', 'image', 'name', 'available') as $prop) { if (isset($methodForConfig[$prop])) { $dbMethod[$prop] = $methodForConfig[$prop]; $shouldSave = true; @@ -4894,7 +4901,7 @@ public function displayAjaxMollieMethodConfig() return array( 'success' => true, - 'methods' => $dbMethods, + 'methods' => $methodsForConfig, ); } @@ -5170,8 +5177,8 @@ public function hookActionOrderStatusUpdate($params = array()) $shipmentInfo = static::getShipmentInformation($idOrder); if (!(Configuration::get(static::MOLLIE_AUTO_SHIP_MAIN) && $orderStatus->shipped - || in_array($orderStatusNumber, $checkStatuses) - ) || $shipmentInfo === null) { + || in_array($orderStatusNumber, $checkStatuses) + ) || $shipmentInfo === null) { return; }