Prestashop: rapid fire bug in checkout address tab give error "no carriers available" and create multiple addresses in DB

Created on 26 Sep 2019  路  10Comments  路  Source: PrestaShop/PrestaShop

Hello, That's my first issue open here and I hope to do everything right. Please forgive me if I do something wrong!

There is a problem that is driving me crazy: in prestashop 1.7.5.1 checkout, when I create a new address, if I click more than once on "Continue" button, i've got the error "no carriers for the selected address in the carrier's tab.

Here is how to reproduce the issue:

1- Place a product in the cart.
2- Go to checkout and register, or place the order as guest.
3- insert a new address
4- click on the button "continue" in address tab multiple times, and here you got the error.

Plus, if you go back to your address, you can see that you have created a new address for every click you did in "Continue button" in address tab... that's bad!

The only way to fix this (via frontend) will be to empty and fill the cart again, but I really need a real fix for this, customers keep calling and I'm losing a lot of orders!

Thanks for anyone will help me!

PS version: 1.7.5.1

1.7.5.2 1.7.6.1 Bug Carriers Checkout FO Fixed Minor PR available develop

Most helpful comment

Prestashop acts funny when people rage click buttons. Preventing rage clicking client-side (via javascript) sholud prevent some of these issuses.
I will try to put together a PR for this when I have a little time, it should be a simple solution, just disable the button after first click and re-enable it in case some of the fileds have validation errors.

All 10 comments

Hi @andreareyoga,

Thanks for your report.
I manage to reproduce the issue with PS1.7.5.2 & PS1.7.6.1 & develop branch (PS1.7.7.0).
https://drive.google.com/file/d/1j9CFkzEwn7lh7ufIxglvSgQlUBbU0sDZ/view
I鈥檒l add this to the debug roadmap so that it鈥檚 fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request!
Related to https://github.com/PrestaShop/PrestaShop/issues/9932#issuecomment-510054925
Thanks!

Honestly I don't think I'll have enough skills to solve it on my own... I'll follow the tread and hope will be fixed soon!
Thanks

Prestashop acts funny when people rage click buttons. Preventing rage clicking client-side (via javascript) sholud prevent some of these issuses.
I will try to put together a PR for this when I have a little time, it should be a simple solution, just disable the button after first click and re-enable it in case some of the fileds have validation errors.

Prestashop acts funny when people rage click buttons. Preventing rage clicking client-side (via javascript) sholud prevent some of these issuses.
I will try to put together a PR for this when I have a little time, it should be a simple solution, just disable the button after first click and re-enable it in case some of the fileds has a validation error.

I think will be enough... and will be great!

Done. The fix is here: #15710
@andreareyoga, as this fix won't probably be merged until 1.7.7.0, meanwhile I suggest to handle it in custom.js file of your theme (themes/yourTheme/assets/js/custom.js). Add this code:

function handleSubmitButton() {
  // prevents rage clicking on submit button and related issues
  $(document).on("click", '.js-current-step button[type="submit"]', function() {
    var _this = this;

    setTimeout(function() {
      return $(_this).prop("disabled", true);
    }, 0); //defer so the form still submits

    $("input[required]").on("invalid", function(e) {
      setTimeout(function() {
        return $('.js-current-step button[type="submit"]').prop(
          "disabled",
          false
        );
      }, 0);
    });
  });
}

$(document).ready(function() {
  if ($("#checkout").length === 1) {
    handleSubmitButton();
  }
});

Then, clear cache and test.

Done. The fix is here: #15710
@andreareyoga, as this fix won't probably be merged until 1.7.7.0, meanwhile I suggest to handle it in custom.js file of your theme (themes/yourTheme/assets/js/custom.js). Add this code:

function handleSubmitButton() {
  // prevents rage clicking on submit button and related issues
  $(document).on("click", '.js-current-step button[type="submit"]', function() {
    var _this = this;

    setTimeout(function() {
      return $(_this).prop("disabled", true);
    }, 0); //defer so the form still submits

    $("input[required]").on("invalid", function(e) {
      setTimeout(function() {
        return $('.js-current-step button[type="submit"]').prop(
          "disabled",
          false
        );
      }, 0);
    });
  });
}

$(document).ready(function() {
  if ($("#checkout").length === 1) {
    handleSubmitButton();
  }
});

Then, clear cache and test.

Works perfectly! Thanks!!!!

Hi,
This solution cannot work well and is not sufficient. The patch does not provide for updating the data in the current Cart object and in the Checkout Session data. The variable in smarty is therefore empty and until the current cart problem is removed, the problem remains the same.
2019-12-03_22-51-53

Hi @elrosi,

You are right.
This issue is not fixed with the Develop branch.
https://drive.google.com/file/d/1cynfiWmD8MBFVAYBIupOzCfngRUWW5HT/view
Steps to reproduce the issue:

  1. Go to FO
  2. Create a new customer
  3. add some products to the cart => process to the checkout page
  4. Add new address
  5. Click quickly several times on the continue button

https://drive.google.com/file/d/1WHLw2vrn2c9KTYxmMuH5BQpGERNjWFzE/view
I will re-open this issue since it is not fixed.

Thanks!

Hi @colinegin,

What do you think?
We should remove this issue from the kanban?
Thanks!

I've put it back it to do. Thanks @khouloudbelguith !

Was this page helpful?
0 / 5 - 0 ratings