[TYPO3-commerce] forms are not pre-filled when browsing checkout's steps
Thibaut van de Mortel
tibo at goutemesdisques.com
Sat Jan 5 21:23:25 CET 2008
Hello list,
hello Ingo, I think you could be interested in this :
when you browse back checkout's steps, the forms are not pre-filled
correctly. There are 3 radio boxes to fill : 1) "billing address", 2)
"use or not a delivery address", 3) "delivery address" (depending on
radio#2 result).
The problem can be summarized like this I think : the current
pre-selection system does not look into $this->MYSESSION.
radio #2)
There is already a pre-selection system for this radio box. But it
pre-selects radio-box according only to current step and to default
behaviour.
So in my case, if I have already filled a delivery address, and I come
back to step#1 (using the step links); then the radio is not filled
correctly. It says "delivery address is the same as billing address".
To resolve the problem I added this after the current pre-selection
system (line 430 of class.tx_commerce_pi3.php) :
---------------------------------------------------------
if(isset($this->MYSESSION['delivery']) &&
!empty($this->MYSESSION['delivery'])){
$deliveryChecked = ' checked="checked" ';
$paymentChecked = ' ';
}
---------------------------------------------------------
That's enough to solve the problem of radio#2.
=============================================================
radio#1 and radio#3)
The preselection of these radios is based on the
$this->piVars['addressid'] variable. But on my installation, this var is
always equal to zero, I don't know why... so the system can only fail to
pre-select correct address.
So I decided to make the same thing with those radios : make the system
look into $this->MYSESSION.
This unfortunately requires editing of 2 files :
modifying the condition on line 298 of class.tx_commerce_pi4.php :
---------------------------------------------------------
$itemMA['###SELECT###'] = '<input type="radio" ';
if($addressType==1){
$tempType = 'billing';
}else{
$tempType = 'delivery';
}
if (($editAddressId == $address['uid'] &&
!isset($this->MYSESSION[$tempType]) ) || (empty($editAddressId) &&
$address['tx_commerce_is_main_address'] && $addressType==1 &&
!isset($this->MYSESSION[$tempType])) || $address['uid'] ==
$this->MYSESSION[$tempType]['uid']) {
$itemMA['###SELECT###'].= 'checked="checked" ';
}
---------------------------------------------------------
But for this to work, pi4 gotta know the object $this->MYSESSION.
So I edited class.tx_commerce_pi3.php to give pi4 the object when it
gets instanciated inside pi3 in line 510 :
$addressMgm->MYSESSION = $this->MYSESSION;
===========================================================
This way, the system looks into the session and pre-select options if
there is any data previously written to session.
This allows for example, a user to go check back the data he previously
inserted ; he only has -for example- to go back to step 1, and then push
"continue" button to review all he has inserted before the final submit.
Everything he already has filled will be correctly pre-selected.
I think it is a usefull feature, which doesn't require much code. This
feature could be present by default on Commerce, in a way or another...
what do you think Ingo ? :)
Regards,
tibo
More information about the TYPO3-project-commerce
mailing list