Describe the bug
Lost carrier restriction data when having 2 carriers withe the same name.
To Reproduce
Let's say we ship for both France and Europe with 2 different carriers due to the delivery time difference:
As you notice here, we have 2 carriers with the same name but with different descriptions. At this moment the table "XXX_module_carrier" has entry for each combination matching a carrier with payment method.
But when we open the "Payment preferences" - section "Carrier restrictions", we notice that there is only one line "UPS Express Saver" instead of 2 (for France and Europe). What happened, is that the query has really returned 2 carriers, but the display shows only one. Thus when we save, one carrier entry in "XXX_module_carrier" will be deleted. And this results in an error message when choosing this latter carrier (the one which has lost its entry in the "XXX_module_carrier" table) during checkout: "Unfortunately, there are no payment method available.".
The workaround is to ensure having carriers with different names: this way it worked. But the "Payment preferences" - section "Carrier restrictions" shows unique names only. And this causes data loss. Is it normal behavior or a bug?
Additional information
PrestaShop version: 1.7.6.1
PHP version: 7.2.18
Hi @jouino16,
I manage to reproduce the issue with PS1.7.6.1 & PS1.7.5.2.
In the carriers Page, I have two carriers

In the Payment preferences, I have only one carrier displayed

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!
Thanks!
@khouloudbelguith
No, I only did a workaround and named the carriers differently as follows:
I searched a bit and I noticed that the data is retrieved correctly from the DB (2 carriers returned), but it looks like the form renderer checks whether it has already rendered a carrier with a specific name to avoid duplicates.
Thank you and have a nice day!
Most helpful comment
@khouloudbelguith
No, I only did a workaround and named the carriers differently as follows:
I searched a bit and I noticed that the data is retrieved correctly from the DB (2 carriers returned), but it looks like the form renderer checks whether it has already rendered a carrier with a specific name to avoid duplicates.
Thank you and have a nice day!