[4.2.1] Complete redesign of PrestaShop country access management module

Control access by country on PrestaShop

When developing modules, the important thing is the feedback from the users and it is not always easy to get it.

Recently, I had a very complicated client to manage with my module allowing to block countries or to redirect them to another URL.

But, in spite of the unpleasant relational experience, it highlighted important points of heating that in the real use of my module and thus led me to completely rework the interface and the procedures of management of the countries.

The problem

Initially, my module list all countries and display the saved redirects directly on a page with a simple text field to limit the display to certain countries.

The problem appeared when we deactivated many countries, a significant slowdown of the display was felt to the point of making its use unpleasant.

I'm surprised that I haven't had more recent feedback on this problem that I didn't identify during my development tests.

So I worked on modifying the entire management interface of this module to make it more pleasant and practical.

For the purists, I had fun manipulating the creation of tables in SMARTY to limit the display of a FOREACH according to the result of this first table, a carnage with regard to the performances.

Corrective implementation

So I made 2 important decisions:

  • Use the well-known display and table management script: https://datatables.net/
  • Separate the management of redirects in another individual country view

DataTables

The implementation of DataTables is quite simple but you will see that it brings its share of constraints.

In one line of code we then have the display of a table with a limitation and therefore an automatic Paging.

You can also easily search the entire table, just as you can sort the columns in the order you want, but this is not done by itself when you want to integrate form fields in this table to facilitate management.

In my case the concern came from the Switch elements to activate or not a country, because no information really goes back with these elements, so I had to implement the return of the state of the SWITCHS in the form of text and then ask DataTables to take it into account at the time of a change of state since a change of javascript content does not really impact the data taken into account by the script DataTables.

By not displaying the customization of the redirects I was able to effectively improve the display performance of the page.

But this was not the end of my concern about using DataTables, because you have to know that if you validate the data of a form present in this table processed by DataTables, then only the visible data are transmitted to the form while the user may have changed the activation state of countries that are not visible at the time of the validation

I had, once again, to ruse, which makes that the pagination is deactivated the time to send the form, slight concern of display, I would see the feeling of the users on this point, do not hesitate to announce it to me in the comments if you are user of the module or if you tested it on its demonstration

Separation of customization from redirects

So I created a new view to customize the redirection simply by adding a button at the end of the table row and that this button is subject to the activation status of the country to avoid having fun configuring useless data on a country that we allow.

We arrive on this new view allowing to activate or not the country, it is a reminder which seemed interesting to me to propose even if everything can be configured in the list of the countries.

Here again, the display of the customization fields by language of the redirections disappears if you decide not to block the country in question.

For quite some time, on my modules I accompany all the fields and views of assistance to understand its operation, this point reduces significantly the support on my modules even if it requires me a lot of time in writing and translation.

Conclusion

By making all these changes, I was able to improve the performance as well as the UX of the module to bring a better user experience.

The importance of customer feedback allows me to improve and respond to the real uses of my modules so don't hesitate, all my modules have a direct contact button to contact me.

Demonstration

By using this module in its entirety I have also set up a new demo that allows you to test the module on PrestaShop versions 1.6 and 1.7.

Download the module

Photo gallery

Comments