Skip to content

Commit f47786e

Browse files
committed
fix: sonar issues
1 parent d55f281 commit f47786e

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

assets/javascripts/front/checkout/model/payment/card.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ let pagarmeCard = {
256256
if (!elem) {
257257
return false;
258258
}
259-
let brand = elem.closest('fieldset').find(this.brandTarget).val();
259+
const brand = elem.closest('fieldset').find(this.brandTarget).val();
260260
let total = elem.closest('fieldset').find(this.valueTarget).val();
261261
if (total) {
262262
total = pagarmeCard.formatValue(total);
263263
}
264-
let cardForm = elem.closest("fieldset");
265-
let select = cardForm.find(this.installmentsTarget);
266-
let info = cardForm.find(this.installmentsInfoTarget);
264+
const cardForm = elem.closest("fieldset");
265+
const select = cardForm.find(this.installmentsTarget);
266+
const info = cardForm.find(this.installmentsInfoTarget);
267267
if (!total) {
268268
total = cartTotal;
269269
}
@@ -273,9 +273,9 @@ let pagarmeCard = {
273273
) {
274274
return false;
275275
}
276-
let storageName = btoa(brand + total);
276+
const storageName = btoa(brand + total);
277277
sessionStorage.removeItem(storageName);
278-
let storage = sessionStorage.getItem(storageName);
278+
const storage = sessionStorage.getItem(storageName);
279279
if (storage) {
280280
select.html(storage);
281281
} else {

src/Block/Checkout/Gateway.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ public function getConfigDataProvider()
8484

8585
/**
8686
* @param string $id
87-
* @return string
87+
* @return string | null
8888
*/
8989
public function getElementId(string $id)
9090
{
9191
if (!$this->getPaymentInstance()){
92-
return;
92+
return null;
9393
}
9494
return WCMP_PREFIX . '[' . $this->getPaymentInstance()->getMethodCode() . ']' . $id;
9595
}

templates/checkout/form/card/installments.phtml

+21-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,27 @@ if (!function_exists('add_action')) {
2020
<?php esc_html_e('Installments quantity', 'woo-pagarme-payments'); ?><span class="required">*</span>
2121
</label>
2222

23-
<?php if ($this->showOneInstallmentInfo()) : ?>
24-
<span data-pagarme-component="installments-info" class="pagarme-installments-info<?= $this->isCcInstallmentTypeByFlag() ? ' pagarme-hidden' : '' ?>">&mdash; <?= __('Your cart has one or more daily or weekly subscription products, which do not allow installments.', 'woo-pagarme-payments')?></span>
23+
<?php if ($this->showOneInstallmentInfo()) :
24+
$installmentsInfo = __('Your cart has one or more daily or weekly subscription products, which do not allow '
25+
. 'installments.', 'woo-pagarme-payments');
26+
?>
27+
<span
28+
data-pagarme-component="installments-info"
29+
class="pagarme-installments-info<?= $this->isCcInstallmentTypeByFlag() ? ' pagarme-hidden' : '' ?>">
30+
&mdash; <?= $installmentsInfo ?>
31+
</span>
2532
<?php endif; ?>
2633

27-
<select id="<?= $this->getElementId('installment') ?>" <?= $this->getInstallmentsComponent() ?> data-total="<?= esc_html($this->getCartTotals()); ?>" data-type="<?= $this->getInstallmentsType(); ?>" data-action="select2" data-required="true" data-element="installments" name="<?= $this->getElementId('installment') ?>">
28-
<?php if ($this->isInterestForAllFlags()) : ?>
29-
<?php foreach ($this->render() as $options) : ?>
30-
<option value="<?= $options['value'] ?>"><?= $options['content'] ?></option>
31-
<?php endforeach; ?>
32-
<?php else : ?>
33-
<option value="">...</option>
34-
<?php endif; ?>
34+
<select
35+
id="<?= $this->getElementId('installment') ?>" <?= $this->getInstallmentsComponent() ?>
36+
data-total="<?= esc_html($this->getCartTotals()); ?>" data-type="<?= $this->getInstallmentsType(); ?>"
37+
data-action="select2" data-required="true" data-element="installments"
38+
name="<?= $this->getElementId('installment') ?>">
39+
<?php if ($this->isInterestForAllFlags()) : ?>
40+
<?php foreach ($this->render() as $options) : ?>
41+
<option value="<?= $options['value'] ?>"><?= $options['content'] ?></option>
42+
<?php endforeach; ?>
43+
<?php else : ?>
44+
<option value="">...</option>
45+
<?php endif; ?>
3546
</select>

0 commit comments

Comments
 (0)