VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: AH on December 17, 2013, 10:46:45 AM

Title: 2.0.26 - Checkout Default country causes confirm and pay to be triggered
Post by: AH on December 17, 2013, 10:46:45 AM
2.0. 26 - When a default country is set in the userfield virtuemart_country_id

On entry to the Checkout

The process behaves as though a valid BT address has been completed

1.)Sets the shipping value for the default country/weight combo
2.) Causes the confirm and Pay message to be presented

Hitting confirm and pay sends the user to the TOS confirm message

Hit confirm and pay after ticking TOS accepted sends the user to the  BT details page (option=com_virtuemart&view=user&task=editaddresscheckout&addrtype=BT)

Turining off the default country works - however making users have to select their country is open to error and (when 99% of the sales are in the same country) is not very good checkout practice



Title: Re: 2.0.26 - Checkout Default country causes confirm and pay to be triggered
Post by: Milbo on December 17, 2013, 11:25:59 AM
Damn

Open in FE/helpers the cart.php. Look in the function checkoutData around line 823. Then search aroudn line 872 for

if (!$validUserDataBT or ($redirect and $validUserDataBT!==true)) {


and replace it by

if ($validUserDataBT!==true) {


Do the same analog with $validUserDataST

If you are already there you may replace also line 860

if((!empty($agreed->required) and empty($agreed->default) and $validUserDataBT!=-1) or $redirect or $this->_dataValidated){

with

if(!empty($agreed->required) and $agreed->default!=='' and $validUserDataBT!==-1){



to get a nicer result, it makes also sense to change a line in the view.html.php cart

line 115 from
if (!$cart->_redirect and !VmConfig::get('use_as_catalog', 0)) {

to if (!$cart->_inCheckOut and !VmConfig::get('use_as_catalog', 0)) {
Title: Re: 2.0.26 - Checkout Default country causes confirm and pay to be triggered
Post by: AH on December 17, 2013, 16:27:21 PM
Many Thanks for the reply Milbo

Is this going to be updated as per your instructions in future releases or will I need to adjust this in every release?

I shall adjust for now and let you know
Title: Re: 2.0.26 - Checkout Default country causes confirm and pay to be triggered
Post by: AH on December 18, 2013, 22:02:44 PM
Milbo made the changes but with the same result.

When going to checkout:-

The Field for Country is completed in the BT address and displayed (even though the complete/edit address link has not been touched)

$this->BT =  {array} [1]
virtuemart_country_id = 222 (defaulted UK)

$validUserDataBT = -1



If I comment our this new piece of code

//vmdebug('prepareAddressDataInCart',$this->$addresstype);
if(empty($this->$type) and $type=='BT'){
$tmp =&$this->$type ;
$tmp = array();
foreach($address['fields'] as $k =>$field){
//vmdebug('prepareAddressDataInCart',$k,$field);
if($k=='virtuemart_country_id'){
if(isset($address['fields'][$k]['virtuemart_country_id']) and !isset($tmp['virtuemart_country_id'])){
$tmp['virtuemart_country_id'] = $address['fields'][$k]['virtuemart_country_id'];
}
} else if($k=='virtuemart_state_id') {
if(isset($address['fields'][$k]['virtuemart_state_id']) and !isset($tmp['virtuemart_state_id'])){
$tmp['virtuemart_state_id'] = $address['fields'][$k]['virtuemart_state_id'];
}
} else if (!empty($address['fields'][$k]['value'])){
if(!isset($tmp[$k])){
$tmp[$k] = $address['fields'][$k]['value'];
}

}

}


The cart performs as expected and the country code is not populated in the array.

Surely some others must have stumbled on this by now?
Title: Re: 2.0.26 - Checkout Default country causes confirm and pay to be triggered
Post by: Milbo on December 19, 2013, 11:34:15 AM
It would be easier, you come in skype to test vm2.0.26a
Title: Re: 2.0.26 - Checkout Default country causes confirm and pay to be triggered
Post by: AH on December 19, 2013, 11:38:56 AM
OK Milbo - will do that when next I have some time.

Thanks for the reply
Title: Re: 2.0.26 - Checkout Default country causes confirm and pay to be triggered
Post by: Milbo on December 19, 2013, 12:03:29 PM
Then it is too late. I cannot reproduce it anylonger. That the default country is already set is not an error.