Fetching basket: not for current user, but for current session

Author Message

Adolfo Barragán

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

Bård Farstad

Wednesday 20 April 2005 3:06:42 am

Adolfo,

I'm not sure if I follow what you are asking for. But the shopping basket is connected to sessions and not users. E.g. if you add some products to the shopping basket and logs in with another user, then the shopping basket will contain the same products. This is intentional because you are often not logged in when you start to add products in the basket.

I hope this answered your question.

--bård

Documentation: http://ez.no/doc

john polo

Friday 06 January 2006 3:35:56 pm

Basket cannot be linked to user instead of session ?

Reason im asking this is that, what if someother user enters the same site in public pc..those products will be shown again to any user that logs on that site

William Steenbergh

Wednesday 11 January 2006 1:31:24 am

I believe the behavior of the basket should be made an INI-setting or something, with one way working on a per-session base, and the other per-user.

I think it's illogical to begin with, if you look at the default settings in ez Publish's ini files.

Bard said this was so anonymoous shoppers could start shopping and not lose the basket when logging on, but then why is the default set to:

{UserSettings]
RequireLogin=true

??
In this default, the user should always be logged on to even see the site, let alone buy stuff. Considering the default settings, the argumentation for this behavior is not logical (but understandable on the whole, though ;-)).

Please consider making this behavior optional. You will save a lot of us headaches and long nights of kernel hacking.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 18:15:17
Script start
Timing: Jan 18 2025 18:15:17
Module start 'layout'
Timing: Jan 18 2025 18:15:17
Module start 'content'
Timing: Jan 18 2025 18:15:18
Module end 'content'
Timing: Jan 18 2025 18:15:18
Script end

Main resources:

Total runtime0.6989 sec
Peak memory usage4,096.0000 KB
Database Queries64

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.1719152.6563
Module start 'layout' 0.00520.0026 740.828139.5078
Module start 'content' 0.00780.6892 780.3359622.6484
Module end 'content' 0.69690.0019 1,402.984412.0938
Script end 0.6989  1,415.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.5006160.0002
Check MTime0.00140.1985160.0001
Mysql Total
Database connection0.00050.071110.0005
Mysqli_queries0.644792.2456640.0101
Looping result0.00060.0858620.0000
Template Total0.672696.220.3363
Template load0.00220.309620.0011
Template processing0.670595.926520.3352
Template load and register function0.00020.022210.0002
states
state_id_array0.00080.118910.0008
state_identifier_array0.00080.117920.0004
Override
Cache load0.00180.2618330.0001
Sytem overhead
Fetch class attribute can translate value0.00080.114440.0002
Fetch class attribute name0.00110.159850.0002
XML
Image XML parsing0.00080.121040.0002
class_abstraction
Instantiating content class attribute0.00000.002950.0000
General
dbfile0.00070.0948170.0000
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs