API
Version 7.x > API > Shopping Cart custom attribute not accessible View modes: 
User avatar
Member
Member
DHood-CPUonline - 12/30/2012 6:15:31 PM
   
Shopping Cart custom attribute not accessible
Hello,

We have added some custom attributes to the Shopping Cart via Developement >> System Tables >> Ecommerce >> Shopping Cart. The field appears in the database structure when the website is run, but we cannot access the field via the API. It does not appear in the ColumnNames of the object nor does it return a value via TryGetValue or GetValue.

Does anyone know how to access these new attributes?

Thanks in advance.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 12/31/2012 2:50:09 AM
   
RE:Shopping Cart custom attribute not accessible
Hello,

I don't know which exact code you are using but you should be able to access the custom fields in Shopping Cart table via
CMS.Ecommerce.ShoppingCartInfo.GetValue("custom_field")
and
CMS.Ecommerce.ShoppingCartInfo.SetValue("custom_field").

I hope this will help you.

Best regards,
Martin Danko

User avatar
Member
Member
DHood-CPUonline - 12/31/2012 9:43:27 AM
   
RE:Shopping Cart custom attribute not accessible
Yes, that is the code we are using (see below)...

' Get the shopping cart
Dim cart As ShoppingCartInfo = ECommerceContext.CurrentShoppingCart

' Set the shopping cart
ShoppingCartInfoProvider.SetShoppingCartInfo(cart)

cart.SetValue("ArtClubCode", "12345")
Dim strArtClubCode As String = cart.GetValue("ArtClubCode")

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 1/2/2013 3:44:00 AM
   
RE:Shopping Cart custom attribute not accessible
Hi,

The code you posted should work. Could you please post a whole file so I can take a look at it with our developers?

Best regards,
Martin Danko

User avatar
Member
Member
DHood-CPUonline - 1/2/2013 11:45:18 AM
   
RE:Shopping Cart custom attribute not accessible
I tried restarting the web server and now it is working, so something must have been in a cache? or? I had tried clearing cookies and temp files in IE and that didn't work.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 1/3/2013 9:41:25 AM
   
RE:Shopping Cart custom attribute not accessible
Hi,

Yes this can be also a reason. Kentico has its own cache and maybe it was a .NET cache. But anyway, I'm glad that you have solved this with a simple restart.

Best regards,
Martin Danko