Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updatePosition #46

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions view/frontend/templates/component/payment/after.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,28 @@
</div>
</div>
<script>
// Function to update the position of 'already-paid' after 'grand-total'
function updatePosition() {
// Select the elements by their class names
const alreadyPaidElement = document.querySelector('.remaining_amount');
const grandTotalElement = document.querySelector('.grand_total');

// Ensure both elements exist before trying to move them
if (alreadyPaidElement && grandTotalElement) {
// Move the 'already-paid' block after the 'grand-total' block
grandTotalElement.insertAdjacentElement('afterend', alreadyPaidElement);
document.addEventListener('DOMContentLoaded', function() {
function updatePosition() {
// Select the elements by their class names
const alreadyPaidElement = document.querySelector('.remaining_amount');
const grandTotalElement = document.querySelector('.grand_total');

// Ensure both elements exist before trying to move them
if (alreadyPaidElement && grandTotalElement) {
// Move the 'already-paid' block after the 'grand-total' block
grandTotalElement.insertAdjacentElement('afterend', alreadyPaidElement);
}
}
}

document.addEventListener('DOMContentLoaded', function() {
// Call the function on page load
updatePosition();

document.querySelectorAll('input[name="payment-method-option"]').forEach((input) => {
input.addEventListener('change', function() {
setTimeout(function() {
updatePosition();
}, 2000);
});
});
});


Expand All @@ -89,7 +95,7 @@
title: '<?= $escaper->escapeHtml(__('Success')); ?>',
content: '',
showClose: true,
buttons:[],
buttons: [],
close() {
this.showModal = false;
},
Expand All @@ -100,28 +106,29 @@
this.showModal = true;
Object.keys(event.detail.data).forEach((key) => {
this[key] = event.detail.data[key];
})
});
}
});

window.addEventListener('buckaroo-modal-hide', () => {
this.close();
});
}
}
};
},
start() {
const addTask = function() {
hyvaCheckout.navigation.addTask(async () => {
if (window.buckarooTask) {
await window.buckarooTask();
}
})
}
});
};
addTask();
window.addEventListener('checkout:navigation:success', (event) => {
if (event.detail.route === 'payment')
if (event.detail.route === 'payment') {
addTask();
}
});


Expand Down
Loading