16

If a user is a small screen device, there are many situations where they will never see an error message.

I referred this link Usability issues with error/notice/success messages. But do not get any answer

For example,

  1. if they're on the "Shipping" step of the checkout process and an error message is added, they may not see the error message get added to the top of the page.
  2. My suggestion would be to either smooth scroll the user up to the error message, display the error message next to the button.

enter image description here

  • I think this is Magento Issue. – Kushal Jun 14 '18 at 9:31
  • did you find any solution? – Camit1dk Aug 14 '19 at 9:33
0

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.

0

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.

  1. You can debug the Authorize.net method and fix the response message should be shown by Payment component messageContainer.

  2. 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,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.