Nathron Posted February 9, 2013 Share Posted February 9, 2013 Ok so I've set up a state tax rule... that's fine it works great when it's Idaho but, if I put into state ID or Id the tax is not applied I do realize the last form there is invalid. In any case what I needed to do was add 2 separate additional rules in the database table itself with Id and ID. Then of course it works except that it would probably be prudent to validate the input on the state/country boxes or just have a drop down. Ideally something to this effect. List countries states have their values set to the Country/State/Province CODE. This is important for 3rd party addon's and api's etc. Would rather not have to set up a hash-table of country codes just to parse the name to the code for api. While of course the devs of WHMCS would have to set up a hash-table,assoc array or whatever. Same concept in this case. Either way set up your hash-table in the tax look-up or clientsdetails array so that internally whatever the customer selects is converted to Country/State/Province code have one entry related to said Country/State/Province code. Then no matter what they enter as long as it's a valid entry. Raise error if not or just have a select. Tax is applied. I will be duct taping the template together to add this validation in the meantime. In the words of the Late Dale Earnhardt Sr. Nothin a little duct tape can't fix. Updating in a moment with temporary fix. Please note this requires you add State/Province code directly into your database under tax Just duplicate the rules you have and add the codes for each or change the existing lines to state codes instead of the full state name. 0 Quote Link to comment Share on other sites More sharing options...
Nathron Posted February 9, 2013 Author Share Posted February 9, 2013 function hook_somthing(){ $smarty->register_function('statedropdown', 'statedropdown'); } add_hook("ClientAreaPage",1,"hook_something"); function statedropdown($params, &$smarty){ $states = array("AL" => "Alabama", "AK" => "Alaska", "AZ" => "Arizona", "AR" => "Arkansas", "CA" => "California", "CO" => "Colorado", "CT" => "Connecticut", "DE" => "Delaware", "DC" => "District Of Columbia", "FL" => "Florida", "GA" => "Georgia", "HI" => "Hawaii", "ID" => "Idaho", "IL" => "Illinois", "IN" => "Indiana", "IA" => "Iowa", "KS" => "Kansas", "KY" => "Kentucky", "LA" => "Louisiana", "ME" => "Maine", "MD" => "Maryland", "MA" => "Massachusetts", "MI" => "Michigan", "MN" => "Minnesota", "MS" => "Mississippi", "MO" => "Missouri", "MT" => "Montana", "NE" => "Nebraska", "NV" => "Nevada", "NH" => "New Hampshire", "NJ" => "New Jersey", "NM" => "New Mexico", "NY" => "New York", "NC" => "North Carolina", "ND" => "North Dakota", "OH" => "Ohio", "OK" => "Oklahoma", "OR" => "Oregon", "PA" => "Pennsylvania", "RI" => "Rhode Island", "SC" => "South Carolina", "SD" => "South Dakota", "TN" => "Tennessee", "TX" => "Texas", "UT" => "Utah", "VT" => "Vermont", "VA" => "Virginia", "WA" => "Washington", "WV" => "West Virginia", "WI" => "Wisconsin", "WY" => "Wyoming"); $retval = '<select name="state">'; foreach($states as $code => $state){ $retval .= '<option value="'.$code.'" '.($code == strtoupper($params['state']) ? "selected" : "").'>'.$state.'</option>'; } $retval .= '</select>'; return $retval; } Find this in your cart.tpl <td class="fieldarea">{if $loggedin}{$clientsdetails.state}{else}<input type="text" name="state" tabindex="10" style="width:80%;" value="{$clientsdetails.state}" />{/if}</td> replace it with this if you use my function. <td class="fieldarea">{if $loggedin}{$clientsdetails.state}{else}{statedropdown state=$clientsdetails.state}{/if}</td> You may want to change each of these "" => "State Name" to reflect the drop-down in whmcs. It seems the admin uses javascript to generate these. So I might just go ahead and dump country/state code in each value and release a more complete quick fix. Of course you'd still need to use this drop-down for it to work effectively as validation, for which I might need to take the hashtable from the js that runs the admin dropdowns after adding country codes and amend the above to include province's from each country. . 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.