using v 1.9 want to store some property related to customer

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 年 前
I see something like this
NopContext.Current.User.CustomerId

now I want something like this
NopContext.Current.User.CustomerSubTotal
but above changes and I want something like customerid which never changes.

Instead of Session or ViewState I want something which doesn't change unless I modify it...
Where can I store customer related properties and how do I access it.
12 年 前
You can use Customer Attributes - stored in the table Nop_CustomerAttribute

Have a look at the Customer Class (customer.cs) for examples of it's usage in the custom method LastShippingOption.

HTH

Dave
12 年 前
thank you.
Can you please reply to this.
Using v1.9

I want to add a property to customer session.
I don't want it to be changing unless I change it.

I want to add LastLockedPrice to Customer Session

I added it to CustomerSession.cs file
I tried this
NopContext.Current.Session.LastLockedPrice = DateTime.UtcNow;
but it doesn't save it.

I will appreciate if anyone can reply how to add a property to customer's session and it doesn't overwrite.
12 年 前
vasa wrote:
thank you.
Can you please reply to this.
Using v1.9

I want to add a property to customer session.
I don't want it to be changing unless I change it.

I want to add LastLockedPrice to Customer Session

I added it to CustomerSession.cs file
I tried this
NopContext.Current.Session.LastLockedPrice = DateTime.UtcNow;
but it doesn't save it.

I will appreciate if anyone can reply how to add a property to customer's session and it doesn't overwrite.


Hi Vasa,

First of all I'm not sure that's where you should store it - CustomerSession

however if you do want to store the value there add this code to CustomerSession.cs


/// <summary>
/// Gets or sets the last accessed date and time
/// </summary>
public DateTime LastLockedPrice { get; set; }


You should however be able to do the following

BusinessLogic.CustomerManagement.CustomerAttribute item = new BusinessLogic.CustomerManagement.CustomerAttribute();
            item.Key = "LastLockedPrice";
            item.Value = DateTime.UtcNow.ToString();
            NopContext.Current.Session.Customer.CustomerAttributes.Add(item);


Which will store LastLockedPrice in the DB as a string value (Untested)

HTH
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.