orocommerce

Custom shipping method admin form issues


I've created a custom shipping integration (based on this guide) that calculates the shipping price based on a percentage of the subtotal. This percentage is set in the shipping method settings.

Everything works fine on the frontend part, the shipping price is calculated correctly.

The problems I have lies in the admin backoffice, in the shipping method settings page. The first problem that I have is that the text box to set the percentage is preceded by the currency, which will confuse the user as it is expecting not a flat rate price, but a percentage of the order's subtotal.

I have the same problem on the list of added shipping methods, the value I set is preceded by the currency, and this is not good.

There is a "add a template" section in the guide which I followed, but the template doesn't seem to affect anything. I tried putting bogus letters in the template and clearing the cache, but they did not appear anywhere on the settings page.

What I would like to do here is either remove the currency indicator completely, or to replace it with a %.

The second problem I have is that the language isn't taken into account. I have created a messages.en.yml file and a messages.fr.yml file. Both follow the same structure of course, and all strings are translated. But if I set OroCommerce in French, I don't get my translated strings, but the english ones.

Here's a screenshot that shows both my problems :

enter image description here

(Strings like "Price percentage" should be translated)

Do you have an idea on how I could fix these issues? Thanks.


Solution

  • Based on Andrey's answer, I managed to have something that works. I'll add a few more details for anyone that had the same issue.

    For the issue with the translation, it seems that renaming the file by adding the locale messages.fr_FR.yml fixed the issue.

    Concerning the currency part on the admin menu, you have to create a jsmodules.yml file in the Resources/config folder of your bundle, NOT Resources/config/oro, which is why none of my configs were taken into account.

    When writing your jsmodules file, when using map, if you're overriding a JS file, you have to omit the file extension. When you're overriding something else, say an HTML file, you have to put the file extension.

    This is how my file is written :

    map:
      "*":
        oroshipping/js/app/views/shipping-rule-method-view: gdmshipping/js/shipping-rule-method-view
    

    There is one caveat, though. This will replace the display for all shipping integrations, so the currency symbol will be replaced/removed for all other shipping types, such as Flat Rate, so keep this in mind.