VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: z-analysts on August 23, 2012, 17:53:56 PM

Title: How can I remove one US state from drop down list on billing address form?
Post by: z-analysts on August 23, 2012, 17:53:56 PM
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
Title: Re: How can I remove one US state from drop down list on billing address form?
Post by: BoiceNet on August 23, 2012, 23:26:45 PM
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]
Title: Re: How can I remove one US state from drop down list on billing address form?
Post by: ivus on August 23, 2012, 23:41:57 PM
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
Title: Re: How can I remove one US state from drop down list on billing address form?
Post by: BoiceNet on August 24, 2012, 01:30:18 AM
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
Title: Re: How can I remove one US state from drop down list on billing address form?
Post by: z-analysts on August 24, 2012, 02:18:20 AM
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,
Title: Re: How can I remove one US state from drop down list on billing address form?
Post by: ivus on August 24, 2012, 09:14:34 AM
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