function before_address(){
$status = $this->_checkLogin();
if($status){
$user_id = hikashop::loadUser();
if($user_id){
$app =& JFactory::getApplication();
$shipping = $app->getUserState( HIKASHOP_COMPONENT.'.shipping_address',0 );
if(empty($shipping)){
$db =& JFactory::getDBO();
$db->setQuery('SELECT address_id FROM '.hikashop::table('address').' WHERE address_published=1 AND address_user_id='.$user_id);
$address_id = $db->loadResult();
$app->setUserState( HIKASHOP_COMPONENT.'.shipping_address',$address_id );
$app->setUserState( HIKASHOP_COMPONENT.'.billing_address',$address_id );
if(strpos($this->checkout_workflow,'shipping')!==false){
//try to auto select the shipping. If the shipping was selected and that the shipping is on the same step as the previous page, stay on the same page
if(!$this->before_shipping(true) && $this->_getStep('shipping',$this->previous)!==false){
$status = false;
}
}
if(strpos($this->checkout_workflow,'payment')!==false){
//try to auto select the payment. If the payment was selected and that the payment is on the same step as the previous page, stay on the same page
if(!$this->before_payment(true) && $this->_getStep('payment',$this->previous)!==false){
$status = false;
}
}
$this->initCart(true);
$this->cart_update = true;
$this->initCart();
}
}
}
}