Magento Asked by Jaimin on December 26, 2021
If a user is a small screen device, there are many situations where they will never see an error message.
I referred to this link
Usability issues with error/notice/success messages. But do not get any answer
For example,
You can change the Error message location to the bottom of the content by overriding the checkout_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<move element="messages" destination="content.bottom"/>
</body>
</page>
Please let me know whether working or not.
Answered by Sathya on December 26, 2021
By default, all most payment methods will extend the default payments method component, this default payment will define the child messagesContainer component inside the payment.
ref: module-checkout/view/frontend/web/js/view/payment/default.js
I don't know what Magento versions but you are using Authorize.net, it may be out of updated version, the error message was shown on the global message component.
You can debug the Authorize.net method and fix the response message should be shown by Payment component messageContainer.
To cheat this case as you want that scroll top when clicking place order, you can override the js file module-checkout/view/frontend/web/js/view/payment/default.js on your template.
or create a mixin for this file module-checkout/view/frontend/web/js/view/payment/default.js on your custom module.
My Magento version: 2.3.2
requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Checkout/js/view/payment/default': {
'Namespace_Youcustommodule/js/view/payment/default-mixin': true
}
}
}
};
Your custom mixin js/view/payment/default-mixin.js
define(function () {
'use strict';
var mixin = {
placeOrder: function (data, event) {
var self = this;
if (event) {
event.preventDefault();
}
//Scroll to top
window.scrollTo({top: 0, behavior: 'smooth'});
if (this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false);
this.getPlaceOrderDeferredObject()
.fail(
function () {
self.isPlaceOrderActionAllowed(true);
}
).done(
function () {
self.afterPlaceOrder();
if (self.redirectAfterPlaceOrder) {
redirectOnSuccessAction.execute();
}
}
);
return true;
}
return false;
}
};
return function (target) {
return target.extend(mixin);
};
});
Note that: This is not a good solution, I prefer to fix directly on your payment method as solution 1.
Regards,
Answered by vinhphon on December 26, 2021
A possible quick solution could be using high-level programming languages like Javascript.
Just check if the error div has value in it using selector in jQuery/Javascript, and then add a jQuery script to scroll to top:
$(window).scrollTop(0);
You could also add smooth effect if you wish to.
Answered by Gideon Babu on December 26, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP