0

can you please help me how to Show a confirmation pop up in check out page while submitting the form in magento2.

  • What's the form which you try to submit? – Khoa TruongDinh Nov 28 '17 at 2:42
  • Place order button – Nagaraju K Nov 28 '17 at 3:42
1

Copy file from

vendor/magento/module-checkout/view/frontend/web/js/view/payment/default.js

to

app/design/frontend/vendor/theme/Magento_Checkout/web/js/view/payment/default.js

find placeOrder: function (data, event) and edit this function as given below

if(confirm("Are you sure to place order?") == true){
   //default function code
}else{
   return false;
}

e.g.

placeOrder: function (data, event) {

            if(confirm("Are you sure to place order?") == true){
                var self = this;

                if (event) {
                    event.preventDefault();
                }

                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;
            }else{
                return false;
            }
        },

Now run php bin/magento setup:static-content:deploy command.

  • 1
    I have checked it, and it's working fine. Ask me if you encounter any problem. – Dinesh Yadav Nov 28 '17 at 5:51
  • thanks dinesh you have saved my time it's working prntscr.com/hg6wbe – Nagaraju K Nov 28 '17 at 6:35
  • 1
    I’m happy to help :) – Dinesh Yadav Nov 28 '17 at 6:47
  • On Place order button it works fine, How can we apply same on "continue to Paypal" (Under paypal method - before redirecting to paypal)? – GunJan Mehta Aug 2 at 10:09
  • @GunJanMehta You have to make changes paypal.js file which is located at vendor/magento/module-braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js There you will find a function payWithPayPal: function () { You have to add the logic in this function. – Dinesh Yadav Aug 8 at 7:33

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.