Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Colin Browne 31 posts 52 karma points
    May 17, 2011 @ 12:37
    Colin Browne
    0

    Separate baskets for site members

    How does one implement separate baskets for site members?

    Ie, if I logon under my account it shows me my basket, if someone else logs on under their account it shows theirs.

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 17, 2011 @ 12:59
    Søren Spelling Lund
    0

    uCommerce supports this out of the box.

    By default we use a cookie to find your basket so it doesn't matter if you're logged in or not. If you want to support multiple customers logging in from the same machine you can override OrderContext.GetBasket and implement the behavior you want.

    Once implemented you register your custom OrderContext in /umbraco/ucommerce/configuration/components.config

    Hope this helps.

  • Colin Browne 31 posts 52 karma points
    May 17, 2011 @ 15:51
    Colin Browne
    0

    Thanks for the reply!

    Are there any examples of how this is done?

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 18, 2011 @ 10:36
    Søren Spelling Lund
    0

    Hi Colin,

    There wasn't yesterday when you posted this, but I thought it was an interesting question to make some documentation out of. So I made this article Changing the Default Basket Behavior of uCommerce that outlines how to do it.

    Hope it helps.

  • Colin Browne 31 posts 52 karma points
    May 19, 2011 @ 14:28
    Colin Browne
    0

    Thanks a lot for the article, it helped a ton, and got what I needed, functioning in the end!

     

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 19, 2011 @ 15:17
    Søren Spelling Lund
    0

    Wonderful. Glad to hear it.

  • Colin Browne 31 posts 52 karma points
    May 23, 2011 @ 12:04
    Colin Browne
    0

    I seem to have a weird issue with it.

    If you don't log in it uses one basket, if you do log in it uses a second basket as intended. However this second basket is the same no matter who is logged in. I'm sure i copied your code correctly...

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 23, 2011 @ 22:03
    Søren Spelling Lund
    0

    The basket for anonymous users is cookie based so it's effectively tied to the computer (as the cookie is stored there). You could migrate the basket content from the anonymous basket when the customer logs in and clear the anonymous one. Seeing as only one person can use the same computer at once that would fix the issue.

    Could I ask what the specifc scenario is that you require behavior like this? Are you dealing with an in store type scenario where multiple people use the same computer to shop?

     

  • Colin Browne 31 posts 52 karma points
    May 24, 2011 @ 13:29
    Colin Browne
    0

    Say for example if i create two accounts, User1 and User2, that means if i use my local PC to access the site, there should be 3 baskets:

    One for an anonymous user, one for User1 and one for User2.

    The anonymous user has a seperate basket which is what I want,

    However both User1 and User2 share the same basket... not what i want.

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 25, 2011 @ 10:34
    Søren Spelling Lund
    0

    I misunderstodd the problem :)

    A tiny snuck into the code.

    You need to replace the original LINQ expression for grabbing the basket based on member id with this updated version. Notice that I forgot to look at order properties for individual orders.

    private Basket GetBasketForCurrentMember()
    {
        PurchaseOrder order = PurchaseOrder.SingleOrDefault(
            x => x.OrderProperties.Where(y => y.OrderId == x.OrderId && y.Key == "MemberId" && y.Value == Member.CurrentMemberId().ToString()).Count() > 0 
                && x.OrderStatusId == 1);
    
        if (order != null) return new Basket(order);
    
        return null;
    }

    Sorry about the inconvenience.

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 25, 2011 @ 10:36
    Søren Spelling Lund
    0

    I updated the original article as well to be on the safe side :)

  • Colin Browne 31 posts 52 karma points
    May 27, 2011 @ 17:21
    Colin Browne
    0

    Thanks, everything works now!

  • Ivan Saric 40 posts 89 karma points
    Jan 06, 2014 @ 13:29
    Ivan Saric
    0

    Hi all,

    I tried this code and I have a problem with LINQ:

    int currentMemberId = umbraco.cms.businesslogic.member.Member.CurrentMemberId();

    UCommerce.EntitiesV2.PurchaseOrder order = UCommerce.EntitiesV2.PurchaseOrder.SingleOrDefault(

                    x => x.OrderProperties.Where(y => y.OrderPropertyId == x.OrderId && y.Key == "MemberId" && y.Value == currentMemberId.ToString()).Count() > 0

                       && x.OrderStatus.Id == 1);

    Error is :

    could not resolve property: Id of: UCommerce.EntitiesV2.OrderStatus [.SingleOrDefault[UCommerce.EntitiesV2.PurchaseOrder](NHibernate.Linq.NhQueryable`1[UCommerce.EntitiesV2.PurchaseOrder], Quote((x, ) => (AndAlso(GreaterThan(.Count[UCommerce.EntitiesV2.OrderProperty](.Where[UCommerce.EntitiesV2.OrderProperty](x.OrderProperties, (y, ) => (AndAlso(AndAlso(Equal(y.OrderPropertyId, x.OrderId), String.op_Equality(y.Key, p1)), String.op_Equality(y.Value, p2))), ), ), 0), Equal(x.OrderStatus.Id, 1)))), )]

    Any idea what is wrong?

    I'm using Umbraco 6.1.6 + uCommerce 4.0.6.

  • Jesper Nielsen 141 posts 498 karma points
    Jan 13, 2014 @ 15:03
    Jesper Nielsen
    0

    Hi Ivan,

    Please try using "&& x.OrderStatusId == 1" instead of "&& x.OrderStatus.Id == 1". Notice the missing dot "."!

    Kind regards,

    Jesper

  • Balbir 10 posts 52 karma points
    Aug 03, 2014 @ 17:31
    Balbir
    0

    Hi all,

    I am getting this error - 

    " The property or indexer 'UCommerce.EntitiesV2.PurchaseOrder.OrderStatusId' cannot be used in this context because the set accessor is inaccessible "

    Please advise.

     

    thanks,

    balbir

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 12, 2014 @ 11:02
    Søren Spelling Lund
    0

    Hi Balbir,

    You might be using a single "=" sign instead of two to make the comparison. .NET thinks you're trying to assign a value instead of compare it.

    You want:

    OrderStatusId == 1

    As opposed to

    OrderStatusId = 1

    Hope this helps.

Please Sign in or register to post replies

Write your reply to:

Draft