[TYPO3-commerce] RFC 7738: basketStoragePid through setup

Rik Willems rik at actiview.nl
Wed May 12 15:21:15 CEST 2010


Hi Morten,

Thank you for your extensive reply. Let me extend on my thoughts a bit.

In tx_commerce_div::initializeFeUserBasket() the basket is initialised. 
If no basket exists in the user the session is taken and if it is empty 
an new one is created. See code:
---
if(is_object($GLOBALS['TSFE']->fe_user->tx_commerce_basket)) {
	return;
}
$BasketID = $GLOBALS['TSFE']->fe_user->getKey('ses', 'commerceBasketId');
	
if (empty($BasketID)) {
	$BasketID = md5($pObj->fe_user->id.':'.rand(0,PHP_INT_MAX));
	$GLOBALS['TSFE']->fe_user->setKey('ses', 'commerceBasketId', $BasketID);
}
---

For that reason I append the actual pid to 'commerceBasketId' in my 
patch. This why only the correct session id can be retrieved for each 
shop. All other functions (like store_data_to_database) depend on this 
session so it can never go wrong. When you checkout one shop, that 
basket is converted and unset while the other basket remains existing.

So, actually what you describe is being done in the patch.

Looking forward to your thoughts.

Cheers!


Morten Olesen schreef:
> Hi Rik,
> 
> I see. The baskets are tied to the baskethash, each shop should generate 
> it's own basket hash. Your solution might work but what happens when in 
> one of the shops the user pushes "empty basket" or when check out is 
> completed and the basket is turned into an order?
> 
> Basically what I'm getting at is since the basket pid has been global 
> always it stands to reason that people might've forgotten to limit 
> queries to it, so you will want to tread carefully.
> 
> For instance "tx_commerce_basket->store_data_todatabase" starts out 
> deleting all entries matching basket hash regardless of pid.
> 
> Given this behaviour it would prehaps be wiser to simply change
> 
> the fe_users session variable "commerceBasketId" depending on wich shop 
> he is viewing ( ie generate it based on user id and shop name or the like )
> 
> see
> tx_commerce_div->initializeFeUserBasket
> 
> A hook in that function would solve your issue more elegantly I think.
> 
> Just my 2c
> 
> /Morten Olesen
> 
> On 2010-05-12 08:53, Rik Willems wrote:
>> Hi Morten,
>>
>> Thank you for your comment.
>> The basket storage pid is used by fe users/visitors to group their
>> basket articles. If you have two different shops in your website (and
>> perhaps too when you run two seperate webshops in one installation) all
>> added articles are combined in one basket. So, basket articles of shop 1
>> are shown in shop 2 as well.
>>
>> This patch fixes that while maintaining backward compatabillity.
>>
>> In pi1 you can set the root catUid, but this is not taken into account
>> when collecting all basket articles.
>>
>> Does this clear it up?
>>
>> Rik
>>
>> Morten Olesen schreef:
>>> Hi Rik,
>>>
>>> I'm at a bit of a loss as to why you would want to change the basket
>>> storage pid, I saw your other mail about two shops - but baskets
>>> arent' used by the store owner until they are converted to orders.
>>>
>>> /Morten Olesen
>>>
>>> On 2010-05-10 17:53, Rik Willems wrote:
>>>> Currently the pid where baskets are stored can only be set globaly
>>>> through the EM. This patch adds a config variable that is read through
>>>> the setup. This way you can use multiple shops/baskets on one
>>>> installation.
>>>>
>>>> To maintain backward compatability a check is made if the setting
>>>> exists. If it doesn't the EM setting is taken.
>>>>
>>>> Looking forward to your feedback!
>>>>
>>>> Forge has a diff.txt to check it out:
>>>> http://forge.typo3.org/issues/show/7738
>>>>
>>>> Cheers, Rik
>>>
> 


More information about the TYPO3-project-commerce mailing list