Skip to content

Commit 6b9aa1d

Browse files
authored
Merge pull request #184 from paynl/feature/PLUG-5038
PLUG-5038 - Logo and min/max amount fix
2 parents e42b801 + d532b4a commit 6b9aa1d

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

includes/classes/PPMFWC/Gateway/Abstract.php

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,19 @@ public function __construct()
6161
*/
6262
public function getIcon()
6363
{
64-
$brandid = $this->get_option('brand_id');
65-
6664
if (!empty($this->get_option('external_logo')) && wc_is_valid_url($this->get_option('external_logo'))) {
6765
return $this->get_option('external_logo');
6866
}
69-
if (!empty($brandid)) {
70-
return PPMFWC_PLUGIN_URL . 'assets/logos/' . $this->get_option('brand_id') . '.png';
67+
if (!empty($this->get_option('payment_image'))) {
68+
return $this->get_option('payment_image');
7169
}
7270

7371
if (!empty($this->getImagePathName())) {
7472
return PPMFWC_PLUGIN_URL . 'assets/logos/payment_method_groups/' . $this->getImagePathName();
7573
}
7674

77-
return '';
75+
// if any of the above settings are not set use static.pay for checkout images
76+
return 'https://static.pay.nl/payment_profiles/100x100/' . $this->getOptionId() . '.png';
7877
}
7978

8079
/**
@@ -320,21 +319,37 @@ public function init_form_fields()
320319
}
321320

322321
if (
323-
(!$this->get_option('brand_id')) || (strlen($this->get_option('brand_id')) == 0) ||
322+
(!$this->get_option('payment_image')) || (strlen($this->get_option('payment_image')) == 0) ||
324323
(!$this->get_option('min_amount')) || (strlen($this->get_option('min_amount')) == 0) ||
325324
(!$this->get_option('max_amount')) || (strlen($this->get_option('max_amount')) == 0) ||
326325
$this->get_option('description') == 'pay_init'
327326
) {
328327
try {
329328
$paymentOptions = PPMFWC_Helper_Data::getPaymentOptionsList();
330-
$payDefaults = (isset($paymentOptions[$optionId])) ? $paymentOptions[$optionId] : array();
329+
330+
if (is_array($paymentOptions)) {
331+
foreach ($paymentOptions as $option) {
332+
if ($option->getId() == $optionId) {
333+
$payDefaults = $option;
334+
break;
335+
}
336+
}
337+
}
331338
} catch (Exception $e) {
332339
$payDefaults = array();
333340
}
334341

335-
$this->set_option_default('brand_id', (isset($payDefaults->brand->id)) ? $payDefaults->brand->id : '', true);
336-
$this->set_option_default('min_amount', (isset($payDefaults->min_amount)) ? floatval($payDefaults->min_amount / 100) : '', false);
337-
$this->set_option_default('max_amount', (isset($payDefaults->max_amount)) ? floatval($payDefaults->max_amount / 100) : '', false);
342+
if ((isset($payDefaults))) {
343+
$minAmount = $payDefaults->getMinAmount();
344+
$maxAmount = $payDefaults->getMaxAmount();
345+
346+
$im = str_replace(['/payment_methods/', '.svg'], ['', '.png'], $payDefaults->getImage());
347+
$image = PPMFWC_PLUGIN_URL . 'assets/logos/' . $im;
348+
}
349+
350+
$this->set_option_default('payment_image', (isset($image)) ? $image : '', true);
351+
$this->set_option_default('min_amount', (isset($minAmount)) ? floatval($minAmount / 100) : '', false);
352+
$this->set_option_default('max_amount', (isset($maxAmount)) ? floatval($maxAmount / 100) : '', false);
338353

339354
$pubDesc = (isset($payDefaults->brand->public_description)) ? $payDefaults->brand->public_description : sprintf(esc_html(__('Pay with %s', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)), $this->getName()); // phpcs:ignore
340355
$this->set_option_default('description', $pubDesc, true);

0 commit comments

Comments
 (0)