Jump to content

Carriers : trying to make "carrier name" translatable


Mooks67

Recommended Posts

Hi there,

Prestashop is sometimes kinda obscure when it comes to implement some core adjustement. What I wish to do is to be able to make the carrier name a translatable field (in short, like the delay field which has a dropdown to its right side in order to change the label for each boutique language).

I have properly modified the form in controllers/admin/AdminCarrierWizardController.php (i'll make an override later on) by adding a line (lang => true), which allows me to display this language selector like the delay field :

public function renderStepOne($carrier)
{
    $this->fields_form = array(
        'form' => array(
            'id_form' => 'step_carrier_general',
            'input' => array(
                array(
                    'type' => 'text',
                    'label' => $this->trans('Carrier name', array(), 'Admin.Shipping.Feature'),
                    'name' => 'name',
                    'lang' => true,
                    'required' => true,
                    'hint' => array(
                        $this->trans('Allowed characters: letters, spaces and "%special_chars%".', array('%special_chars%' => '().-'), 'Admin.Shipping.Help'),
                        $this->trans('The carrier\'s name will be displayed during checkout.', array(), 'Admin.Shipping.Help'),
                        $this->trans('For in-store pickup, enter 0 to replace the carrier name with your shop name.', array(), 'Admin.Shipping.Help'),
                    ),
                ),
            ),
        ),
    );
}

I have added this same element 'lang' => true in the array of the ObjectModel definition in Carrier.php:

'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCarrierName', 'required' => true, 'size' => 64)

But the problem is that leads to nothing, because when I'm trying to save the multi steps form, a jQuery error happens with something like :

Quote

parserError [Object, Object].

I have then tweaked a bit the carrier_wizard.js file and changed dataType=json to dataType=html in order to get rid of the error. But nothing is saved in the DB.

I have then manually added a new column in the ps_carrier_lang table, called "name", in order to have the place to save the translations. But it doesn't work.

Do you guys have any idea on how to achieve this translation with the Prestashop way?
image.png.026255fb1c76d2dcb6ed47d4478e7063.png

Edited by Mooks67
Image update (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...