CMS MADE SIMPLE FORGE

Orders

 

[#8349] Country is not selected in the order processing

avatar
Created By: eduardo (cosmicfrog)
Date Submitted: Wed Sep 05 14:01:46 -0400 2012

Assigned To: Robert Campbell (calguy1000)
Version: 1.13.1
CMSMS Version: 1.10.2
Severity: Minor
Resolution: None
State: Open
Summary:
Country is not selected in the order processing
Detailed Description:
The Country field doesn´t get the content of the field in FEU, the dropdown(in
the order processing template) shows always the first country in the list.

I mapped a text field from FEU to Country field in Orders but it is not selected
when ordering.

I search in module's code(moform.inc.php in lib\classes\module_support)  and see
that only it only selects if value is equal, but what is passed from the textbox
is the key.

My solution was to add another condition on line 345:  ||
$selectedvalue==strtoupper($key)


History

Comments
avatar
Date: 2012-09-30 17:11
Posted By: adrien jaures (adrienj)

Same problem.
Thank you for this solution eduardo.
      
avatar
Date: 2016-09-14 14:54
Posted By: Deleted User (deleteduser_11200)

This still applies to Orders -> 1.18.4  

It is weird/unexpected that values entered in: Order Manager -> Preferences ->
Valid Countries (fields) get converted.

For Example: 
Netherlands=Netherlands is uppercased to: NETHERLANDS=Netherlands

Can be fixed in the get_country_list() function : /modules/Orders.module.php
line 223.

! BTW get_state_list() function : /modules/Orders.module.php line 241 does not
change values entered, as expected.

If code changes are not desired,  this behaviour should be documented more
clearly.
Something like:
-  use a uppercased 2 or 3-letter iso country when you give in countrird,
-  states are not affected

NL=Netherlands (ISO code 2 letters)
NLD=Netherlands (ISO code 3 letters)


  // snippet from  /modules/Orders.module.php 

    protected function get_country_list()
    {
        $tmp = $this->GetPreference('valid_countries','');
        if( !$tmp ) return parent::get_country_list();

        $tmp2 = explode("\n",$tmp);
        $tmp3 = array();
        foreach( $tmp2 as $one ) {
            if( strstr($one,'=') === FALSE ) continue;
            $one = trim($one);
            list($code,$name) = explode('=',$one,2);
            $code = trim($code);
            $name = trim($name);
            $tmp3[] = array('name' => $name, 'code' => strtoupper($code));
        }
        return $tmp3;
    }

   protected function get_state_list()
    {
        $tmp = $this->GetPreference('valid_states','');
        if( !$tmp ) return parent::get_state_list();

        $tmp2 = explode("\n",$tmp);
        $tmp3 = array();
        foreach( $tmp2 as $one ) {
            if( strstr($one,'=') === FALSE ) continue;
            $one = trim($one);
            list($code,$name) = explode('=',$one,2);
            $tmp3[] = array('name' => trim($name), 'code' => trim($code));
        }
        return $tmp3;
    }