Skip to content

Commit

Permalink
Fix agreements accept button disablement
Browse files Browse the repository at this point in the history
  • Loading branch information
s4ddly committed Jan 15, 2024
1 parent 89e85d5 commit 146b7fa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Model/ApiFacade/TpayConfig/ConfigOpen.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ public function fetchJavaScripts()
$script[] = 'tpaycom_magento2basic::js/string_routines.js';
$script[] = 'tpaycom_magento2basic::js/tpayCards.js';
$script[] = 'tpaycom_magento2basic::js/renderSavedCards.js';
$script[] = 'tpaycom_magento2basic::js/tpayGeneric.js';
$scripts = '';

foreach ($script as $key => $value) {
$scripts .= $this->createScript($value);
}
Expand Down
24 changes: 24 additions & 0 deletions view/base/web/js/tpayGeneric.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require(['jquery', 'mage/translate'], function ($, $t) {
const tos = $('.generic_accept_tos');
const payButton = $('.tpaycom_magento2generic_submit');
const methods = $('input[name^="payment"]')


methods.on('click', function () {
payButton.each(function () {
$(this).addClass('disabled')
})
});

tos.on('change', function () {
payButton.each(function () {
$(this).toggleClass('disabled')
})
});

$(document).ready(function () {
payButton.each(function () {
$(this).addClass('disabled')
})
});
});
5 changes: 2 additions & 3 deletions view/frontend/web/template/payment/tpay-generic-onsite.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<div class="TpayRegulations">
<input type="checkbox" name="accept_tos" id="generic_accept_tos"/>
<input type="checkbox" name="accept_tos" class="generic_accept_tos"/>
<label for="generic_accept_tos">
<a target="_blank"
data-bind="attr: {href: getTerms()}, text: $t('I do accept tpay.com service regulations')"></a>.
Expand All @@ -25,8 +25,7 @@
</div>
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
id="tpaycom_magento2generic_submit"
<button class="action primary checkout tpaycom_magento2generic_submit"
type="submit"
data-bind="
click: placeOrder,
Expand Down

0 comments on commit 146b7fa

Please sign in to comment.