If you are shipping only to one country, simplify estimator

When you have only one country to ship to and it is clear that you are shipping only to that country alone, you can simplify your shipping estimation by removing a country field:



shipping_estimation.tpl



Comment the next block with {* } like so:



```php

{




{$lang.country}:



- {$lang.select_country} -

{assign var=“countries” value=1|fn_get_simple_countries}

{foreach from=$countries item=country key=ccode}



*}

```



and add below to the next line



```php

```



And change “US” value to any other if you have a different country.

In addition, if you will look at View Cart page and will notice that it has a lot of states as javascript array that takes about 50% of the whole webpage HTML code. Since we are working only with US, we don’t care about other states and they still load as a webpage source. So, I went ahead and made it load only US states, much smaller HTML code for the view cart page.



profiles_scripts.tpl



I put in if clause with US check:



```php var states = new Array();

{if $states}

{foreach from=$states item=country_states key=country_code}

{if $country_code==“US”}

states[‘{$country_code}’] = new Array();

{foreach from=$country_states item=state name=“fs”}

states[‘{$country_code}’][‘__{$state.code|escape:quotes}’] = ‘{$state.state|escape:javascript}’;

{/foreach}

{/if}

{/foreach}

{/if} ```

It seems like this fix should go in core/fn.locations.php to return only available states in available countries:



```php

85c85,91

< $avail_cond = ($avail_only == true) ? " WHERE a.status = 'A' " : '';


if ($avail_only == true) {

$avail_cond = “WHERE cc.status = 'A' AND a.status = 'A'”;

$avail_join = 'LEFT JOIN ?:countries as cc ON cc.code = a.country_code';

} else {

$avail_cond = '';

$avail_join = '';

}

88c94

< return db_get_array(“SELECT a.state_id, a.code, b.state, c.country FROM ?:states as a LEFT JOIN ?:state_descriptions as b ON b.state_id = a.state_id AND b.lang_code = ?s LEFT JOIN ?:country_descriptions as c ON c.code = a.country_code AND c.lang_code = ?s $avail_cond ORDER BY a.country_code, b.state”, $lang_code, $lang_code);



return db_get_array(“SELECT a.state_id, a.code, b.state, c.country FROM ?:states as a LEFT JOIN ?:state_descriptions as b ON b.state_id = a.state_id AND b.lang_code = ?s LEFT JOIN ?:country_descriptions as c ON c.code = a.country_code AND c.lang_code = ?s $avail_join $avail_cond ORDER BY a.country_code, b.state”, $lang_code, $lang_code);

90c96

< return db_get_hash_multi_array(“SELECT a.country_code, a.code, b.state FROM ?:states as a LEFT JOIN ?:state_descriptions as b ON b.state_id = a.state_id AND b.lang_code = ?s $avail_cond ORDER BY a.country_code, b.state”, array('country_code'), $lang_code);



return db_get_hash_multi_array(“SELECT a.country_code, a.code, b.state FROM ?:states as a LEFT JOIN ?:state_descriptions as b ON b.state_id = a.state_id AND b.lang_code = ?s $avail_join $avail_cond ORDER BY a.country_code, b.state”, array('country_code'), $lang_code);

```




[quote name='TexasGuy' timestamp='1273268946' post='79644']

In addition, if you will look at View Cart page and will notice that it has a lot of states as javascript array that takes about 50% of the whole webpage HTML code. Since we are working only with US, we don't care about other states and they still load as a webpage source. So, I went ahead and made it load only US states, much smaller HTML code for the view cart page.





profiles_scripts.tpl





I put in if clause with US check:





```php var states = new Array();



{if $states}



{foreach from=$states item=country_states key=country_code}



{if $country_code==“US”}



states['{$country_code}'] = new Array();



{foreach from=$country_states item=state name=“fs”}



states['{$country_code}']['__{$state.code|escape:quotes}'] = '{$state.state|escape:javascript}';



{/foreach}



{/if}



{/foreach}



{/if} ```

[/quote]