Wednesday 13 April 2005 5:06:37 am
I need fetch basket for current user, so I use the sample code from http://ez.no/ez_publish/documentation/reference/data_fetching/shop/basket but this function don't retrieve the basket for current user, it retrieve the basket for current session. If I change user in same session, I always get same basket.
This is my code: I've create a template to show a box with basket's items (basket_box.tpl) and I included this template in pagelayout:
{set-block scope=root variable=cache_ttl}0{/set-block}
{let mybasket=fetch( 'shop', 'basket')}
{section show=$mybasket.is_empty|not()}
<div class="rightbox">
<h4>Your Basket</h4>
<div class="rightbox_content">
{section var=item loop=$mybasket.items}
<p>{$item.item_count}x {$item.object_name</p>
{/section}
<div align="right">
<form name="basket_box" method="post" action={"/shop/basket/"|ezurl}>
<input class="button" type="submit" name="CheckoutButton" value="{'Checkout'|i18n('design/standard/shop')}" />
</form>
</div>
</div>
</div>
{/section}
{/let}
If I (anonymous user) buy any products, I can see the box. If (before I checkout) I login on site, I can see the box. When I checkout and confirm, the box dissapear. All of this is Ok.
But... If I don't checkout and I logout, I also see the basket_box. In this case, basket would dissapear (I think) Also, If I logout (from user A) and I login with another user (user B) I still see the basket box. I think basket would dissapear, because the buy is from user A, not from user B. What is wrong in my code?
Thanks in advance Adolfo Barragán
|