2.0.26 - Checkout Default country causes confirm and pay to be triggered

Started by AH, December 17, 2013, 10:46:45 AM

Previous topic - Next topic

AH

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



Regards
A

Joomla 4.4.5
php 8.1

Milbo

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)) {
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

AH

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
Regards
A

Joomla 4.4.5
php 8.1

AH

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?
Regards
A

Joomla 4.4.5
php 8.1

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

AH

OK Milbo - will do that when next I have some time.

Thanks for the reply
Regards
A

Joomla 4.4.5
php 8.1

Milbo

Then it is too late. I cannot reproduce it anylonger. That the default country is already set is not an error.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/