News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How can I remove one US state from drop down list on billing address form?

Started by z-analysts, August 23, 2012, 17:53:56 PM

Previous topic - Next topic

z-analysts

Hi all,

I have a site where we are not selling in one US state because of the complex sales tax rules. To accomplish this I though I could unpublish the one state in the countries configuration. However, the problem I have is that the unpublished state name still appears in the list of US states on the billing address form. How can I remove it from the drop down list?

Thank you!

VM 2.0.8e
Joomla 2.5.6

BoiceNet

Not sure if this is the best place to take care of your request, but there is a table in the database that holds all of the state names. It's the only place I've found which contains a list of all 50 states for the US. You could remove the state from the table and it should no longer show up anywhere there is a listing of states.

[attachment cleanup by admin]

ivus

Hi guys,

There's an admin area to do this.

VirtueMart > Configuration > Countries

In the list of country names you should be able to find the US.

United States  [States]

Click on the part that says "States" and it'll take you to another list that only contains the state from the US.

I hope this helps  ;D

BoiceNet

Excellent! Thank you, ivus.

I figured there was an easier way to take care of this. I did not click on the [states] link in the Countries area. Definitely a better way.

bb

z-analysts

Dear Ivus,

Thank you for your reply however that is what I did. The problem is that the state name still appears in the drop down list on the Add/Edit Billing form.  Please advise.

Regards,

ivus

Hi guys,

OK... I see the problem.

Simple fix : "/administrator/components/com_virtuemart/models/state.php"

Find the following function public function getStates()

ORIGINAL:

public function getStates($countryId, $noLimit=false)
{
$quer= 'SELECT * FROM `#__virtuemart_states`  WHERE `virtuemart_country_id`= "'.(int)$countryId.'"
ORDER BY `#__virtuemart_states`.`state_name`';

if ($noLimit) {
    $this->_data = $this->_getList($quer);
}
else {
    $this->_data = $this->_getList($quer, $this->getState('limitstart'), $this->getState('limit'));
}

if(count($this->_data) >0){
$this->_total = $this->_getListCount($quer);
}

return $this->_data;
}


CHANGED:

public function getStates($countryId, $noLimit=false)
{
$app = JFactory::getApplication ();
$quer = 'SELECT * FROM `#__virtuemart_states`  WHERE `virtuemart_country_id`= "'.(int)$countryId.'"';
if ($app->isSite ()) {
$quer .= ' AND `published`="1" ';
}
$quer .= 'ORDER BY `#__virtuemart_states`.`state_name`';

if ($noLimit) {
    $this->_data = $this->_getList($quer);
}
else {
    $this->_data = $this->_getList($quer, $this->getState('limitstart'), $this->getState('limit'));
}

if(count($this->_data) >0){
$this->_total = $this->_getListCount($quer);
}

return $this->_data;
}


I added a PUBLISHED clause.

Now it should work.

ivus  ;D