[TYPO3-shop] How to put a product into basket out of an own extension?

Franz Holzinger franz at ttproducts.de
Wed Jan 21 11:31:04 CET 2009


Hello Sebastian,

> The basket is stored in Typo3-Session. And in this session stored in the
> key basketExt filled from $this->basketExt. But I dont see whats the
> structure of $this->basketExt is.
> 
> I have a product with the uid 32124, a pid, a title, price and tax. So
> how does the var awaits this data?

tt_products 2.7.0+:

$this->basketExt is an array with the uid of the product as an index and 
a second array as the value. The second array has the variant as an 
index and the amount as the value. So you can see which products are in 
the basket and which variants and variants amounts of it.

Only the uid of the product is stored. The variant string is a ';' 
separated list of the selectable variants. The number in it is the index 
of the possible different values of a variant.

Example:
3
Integer 	1;0;;;;;;;; 	2

The first variant is color. So product 3 is in the basket with the 
second of all possible colors and with the first size. The other 
variants are not available for this product. 2 pieces of it are in the 
basket.

> By the way... Do I have to do something when the user isnt logged in
> when putting something in basket? Maybe save the basket to
> $TSFE->fe_user->setKey('user' ?

No, the basket works even if nobody has logged in.

> Franz Holzinger schrieb:
>> Hello Sebastian,
>>
>>> I have a own extension where I let the user put in a lot of data and out
>>> of that create a product that is stored in table tt_products. Now I want
>>> to put that product into the basket of that user. How?
>> You can store products into the basket:
>>
>> $TSFE->fe_user->setKey('ses','basketExt',$this->basketExt);
>>
>> See the file model/class.tx_ttproducts_basket.php.


More information about the TYPO3-project-tt-products mailing list