Jump to content

custom select box in customer address manager


Recommended Posts

Hi everyone,

I have added a custom field in the address form (point of withdraw aka pow) and I have made an override of the address class and of the AdminAddressesController controller.

Though in the backoffice I see my select box as I wanted, I have not understood properly how to assign to smarty the array that I gget from the getPow() method that I have written.

 

Here is some code:

    public static function getPow()
    {
        $pow = array();
        $i = 0;
        
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM punti_di_ritiro ORDER BY id_country, id_state, city ASC');
        foreach ($result as $row)
        {
            $pow[$i] = $row;
            $i++;
        }

        return $pow;
    }

and in the AdminAddressesController.php

            array(
            'type' => 'select',
            'label' => $this->l('Punto di ritiro'),
            'name' => 'punto_di_ritiro',
            'required' => true,
            'col' => '4',
            'hint' => $this->l('Partner per la consegna con ritiro'),
            'options' => array(
            'query' => Address::getPow(),
            'id' => 'id',
            'name' => 'alias'
            )
            ),

In the address.tpl I should add something like this in order to get the list and put it in the options of the select:

            <div class="required form-group">
                <label for="punto_di_ritiro">{l s='Punto di ritiro'} <sup>*</sup></label>
                <select name="punto_di_ritiro" id="punto_di_ritiro" class="form-control">
                    {$punto_di_ritiro}
                </select>
            </div>

The problem is.... how do I assign the returned array from the getPow() to {$punto_di_ritiro}??

Thank you for any hint, link, suggetion or solution you may want to share with me.

 

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...