[TYPO3-commerce] Problem with country in checkout

Christopher Hlubek hlubek at networkteam.com
Wed Jan 7 13:33:58 CET 2009


Hi Claudius,

Claudius Heitz schrieb:
> I've got a weird problem with the country field in the checkout process
> of commerce.
> 
> As soon as the user comes the last page of the checkout (the listing
> page with an overview) and then goes back to the address page for the
> invoice, the country isn't the chosen one but the first in alphabetic
> order (Afghanistan).

We got the same problem in a fresh commerce install.

> 
> I suppose the problem is, that instead of the country code (eg. DEU for
> Germany) the country name itself is submitted ("Germany"). This I
> recognized in the country field of tt_address that is created after
> finishing the order.

After a lot of debugging in our installation we figured out, that the
value is correctly submitted and processed.

> 
> But why does this happen?
> 
> 
> The weird thing is also that on a local installation of the same shop
> this error doesn't occur.
> 
> Does anyone have an idea where this error could come from?

The main problem is, that the piVars array is written to the session.
With our TYPO3 and PHP versions (4.2.0/5.2.0-8+etch13) the values in the
array are references to strings. In the parseRawData method in
tx_commerce_pi3 some values in the array should be converted (e.g. the
country code to country name) and returned as a new array. In fact, as
the values in the session are string references, the values in the in
the session are overwritten too. So after visting the listing step,
which calls getAddress and parseRawData the session data is modified.

The Problem can be solved by xclassing the  some values in the array
should be converted (e.g. the country code to country name) and returned
as a new array. In fact, as the values in the session are string
references, the values in the in the session are overwritten too. So
after visting the listing step, which calls getAddress and parseRawData
the session data is modified.

The Problem can be solved by modifying the parseRawData method to copy
the values of the given session array to a newly instantiated array:


-------------------------------------------
function parseRawData ($_data=array(),$TS) {
	if (!is_array($_data))	return array();
	if ($this->debug) debug($TS);
	$data = array();
	// Copy the array to dereference values
	foreach ($_data as $key => $value) {
		$data[$key] = $_data[$key];
	}
	foreach ($data as $key => $value) {
		...
	}
	return $data;
}
-------------------------------------------


Greetings,
Christopher


More information about the TYPO3-project-commerce mailing list