Skip to content

Commit 79a2f63

Browse files
authored
Merge branch 'master' into feature/PLUG-5162
2 parents 450c629 + 6b9aa1d commit 79a2f63

2 files changed

Lines changed: 27 additions & 12 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);

includes/classes/PPMFWC/Hooks/FastCheckout/Exchange.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function addAddressToOrder(array $checkoutData, object $order)
3333
'company' => $customerData['company'] ?? '',
3434
'email' => $customerData['email'] ?? '',
3535
'phone' => $customerData['phone'] ?? '',
36-
'address_1' => $billingAddressData['streetName'] . ' ' . $shippingAddressData['streetNumber'] . $shippingAddressData['streetNumberAddition'],
36+
'address_1' => ($billingAddressData['streetName'] ?? '') . ' ' . ($billingAddressData['streetNumber'] ?? '') . ($billingAddressData['streetNumberAddition'] ?? ''),
3737
'address_2' => '',
3838
'city' => $billingAddressData['city'] ?? '',
3939
'state' => '',
@@ -47,7 +47,7 @@ public static function addAddressToOrder(array $checkoutData, object $order)
4747
'company' => $customerData['company'] ?? '',
4848
'email' => $customerData['email'] ?? '',
4949
'phone' => $customerData['phone'] ?? '',
50-
'address_1' => $shippingAddressData['streetName'] . ' ' . $shippingAddressData['streetNumber'] . $shippingAddressData['streetNumberAddition'],
50+
'address_1' => ($shippingAddressData['streetName'] ?? '') . ' ' . ($shippingAddressData['streetNumber'] ?? '') . ($shippingAddressData['streetNumberAddition'] ?? ''),
5151
'address_2' => '',
5252
'city' => $shippingAddressData['city'] ?? '',
5353
'state' => '',

0 commit comments

Comments
 (0)