0

my issue is that a part of my shipping method label isn't properly traducted, so I would like to find where the label is generated.

message

This comes from native : src/vendor/magento/module-checkout/view/frontend/web/template/cart/shipping-rates.html

<label class="label" data-bind="attr: {for: 's_method_' + carrier_code + '_' + method_code}">
    <!-- ko text: $data.method_title --><!-- /ko -->
    <each args="element.getRegion('price')" render="" />
</label>

Doing some digging I found (There it's colissimo but it's the same function called for each delivery methods): src/app/code/Colissimo/Shipping/view/frontend/web/js/view/checkout/sidebar/pickup.js

        getShippingMethodTitle: function () {
            var shippingMethod;

            if (!this.isCalculated()) {
                return '';
            }
            if (!this.address()) {
                return '';
            }

            shippingMethod = quote.shippingMethod();

            return shippingMethod ? shippingMethod['carrier_title'] + ' - ' + shippingMethod['method_title'] : '';
        }

quote.js is the native : src/vendor/magento/module-checkout/view/frontend/web/js/model/quote.js

And from this location I'm lost, it seems that the data i'm looking for is in this array but I don't know how to find where it's really added in the array.

Thanks for your help.

EDIT : src/app/code/Colissimo/Shipping/etc/config.xml

<?xml version="1.0"?>
<!--
/**
 * Colissimo Shipping Module
 *
 * @author    Magentix
 * @copyright Copyright © 2020 Magentix. All rights reserved.
 * @license   https://www.magentix.fr/en/licence.html Magentix Software Licence
 * @link      https://colissimo.magentix.fr/
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <carriers>
            <colissimo>
                <active>0</active>
                <model>Colissimo\Shipping\Model\Carrier\Colissimo</model>
                <title>La Poste : Colissimo</title>
                <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg>
                <active_rma>1</active_rma>
                <is_online>1</is_online>
                <weight_calculation>per_cart</weight_calculation>
                <homecl>
                    <active>0</active>
                    <name>Domicile sans signature</name>
                    <specificcountry>FR</specificcountry>
                </homecl>
                <homesi>
                    <active>0</active>
                    <name>Domicile avec signature</name>
                    <specificcountry>FR,BE,NL,DE,GB,LU,ES</specificcountry>
                </homesi>
                <pickup>
                    <active>0</active>
                    <name>Point de retrait</name>
                    <specificcountry>FR,BE,NL,DE,GB,LU,ES</specificcountry>
                    <open>1</open>
                    <apply_default>0</apply_default>
                    <default_city>Paris</default_city>
                    <default_postcode>75001</default_postcode>
                    <default_country>FR</default_country>
                    <map_type>osm</map_type>
                    <remove_selection>0</remove_selection>
                </pickup>
                <international>
                    <active>0</active>
                    <name>Expert International</name>
                    <specificcountry>DK,DE,IE,EL,ES,IT,LU,NL,AT,PL,PT,FI,SE,UK</specificcountry>
                </international>
                <domtomcl>
                    <active>0</active>
                    <name>Outre-Mer sans signature</name>
                    <specificcountry>GP,MQ,GF,RE,PM,YT,TF,WF,PF,NC,BL,MF</specificcountry>
                </domtomcl>
                <domtomsi>
                    <active>0</active>
                    <name>Outre-Mer avec signature</name>
                    <specificcountry>GP,MQ,GF,RE,PM,YT,TF,WF,PF,NC,BL,MF</specificcountry>
                </domtomsi>
                <domtomeco>
                    <active>0</active>
                    <name>Outre-Mer Eco</name>
                    <specificcountry>GP,MQ,GF,RE,PM,YT,TF,WF,PF,NC,BL,MF</specificcountry>
                </domtomeco>
            </colissimo>
        </carriers>
    </default>
</config>

1 Answer 1

0

On your app\code\vendor\module\etc\config.xml

Place translate=true on your delivery method title. here is an example:

<pickupstore>
                <active>1</active>
                <title translate="true">Pickup in store</title>
                <sallowspecific>0</sallowspecific>
                <sort_order>16</sort_order>
                <model>vendor\module\Model\Carrier\PickupStoreCustomMethod</model>
            </pickupstore>
3
  • Not sure what you are refering to; looks like I have no <pickupstore> tag in my code. Moreover, the title is already translated, it's just a part of the title which isn't (the day is in french which is fine and the month is in english which isn't). This probably means the code just need to add the translation before concatenate the month...but I can't find where it is
    – Claims
    Commented Jul 1, 2021 at 9:08
  • pickupstore is the code of my custom delivery method (assuming you are using a custom one)
    – Joao71
    Commented Jul 1, 2021 at 10:01
  • Found the file you were refering to, but it looks like i got it wrong, it's not really the title it's the date i need to translate. (and i thought it was inside the title due to the code i founded earlier). I will add the file content
    – Claims
    Commented Jul 1, 2021 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.