Skip to content

Commit

Permalink
Fix method config
Browse files Browse the repository at this point in the history
  • Loading branch information
snowycatsoftware committed Oct 22, 2018
1 parent 71b3eb5 commit 8fce5f2
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -4894,7 +4901,7 @@ public function displayAjaxMollieMethodConfig()

return array(
'success' => true,
'methods' => $dbMethods,
'methods' => $methodsForConfig,
);
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 8fce5f2

Please sign in to comment.