Adding custom fields

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
myvo04
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 29
Joined: Thu Apr 24, 2008 8:14 am

Adding custom fields

Post by myvo04 » Tue Apr 14, 2009 9:49 am

We would like to add a couple of custom fields on the checkout page of the order process--an Industry Code dropdown list and an Order Source dropdown list. It would be nice if we can store the Industry Code data with the customer information (i.e. address) and the Order Source data is only valid with one specific order. Where do you recommend placing these fields as far as the table data goes? I understand there is a user settings table available--do you think this is most appropriate for the Industry Code? What about Order Source? We would like to be able to refer back to this data in the admin interface if possible. Other than writing custom code, is there anything else we need to do with the user settings table to store the industry code data? I'm very new at customizing AbleCommerce and usually code in VB...any help would be great. Thanks in advance.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Adding custom fields

Post by mazhar » Tue Apr 14, 2009 10:33 am

It would be nice if we can store the Industry Code data with the customer information (i.e. address)
If you want to store industry code data with each user without making database change then it would be better to make use of Comment field available with customer information instead of using user settings. Please read following post
viewtopic.php?f=47&t=6813
the Order Source data is only valid with one specific order
Secondly regarding Order Source information one solution could be to make use of ac_CustomFields. Please read following thread about their use
viewtopic.php?f=42&t=8651

The other possible solution could be to create some custom table to store this information. If you want to proceed with this then read following thread about auto generating data access code for your custom table
viewtopic.php?f=47&t=9530

myvo04
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 29
Joined: Thu Apr 24, 2008 8:14 am

Re: Adding custom fields

Post by myvo04 » Thu Apr 16, 2009 8:36 am

I started out trying to implement the Industry Code user defined field--the only difference from the example you provided is I need this user defined field on the checkout page so that the customer can identify their industry code. The part I can't seem to get working is getting the comment field to update with a new value. I first added a dropdown list box on the checkout page. Then I added this code to the page load event:
User _User = Token.Instance.User;
IndustryCodeDropDownList.SelectedValue = _User.Comment;

Then I added this code to the continue button click event to save the value to the comment field:
User _User = Token.Instance.User;
_User.Comment = IndustryCodeDropDownList.SelectedValue;
_User.Save();

In testing the changes, I added an item to my basket, proceeded to check out, logged in as a user, indicated "Agent/Broker" as the Industry Code and completed the checkout. When I look in the User table, I do see that "Agent/Broker" is the new value in the comment field. However, when I step through this checkout process a second time using the same user, I choose "Insurance Company" as the Industry Code, but the comment field still shows "Agent/Broker" as the value (it should say "Insurance Company"). Is there something I'm missing?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Adding custom fields

Post by mazhar » Thu Apr 16, 2009 10:07 am

I suspect that its saving the information the only differance is that its saving very same informaton again. Make sure loading code within Page_Load method runs only once. Try putting your industry code loading code within

Code: Select all

if(!Page.IsPostBack)
{
//YOU Industry Loading code here
}

myvo04
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 29
Joined: Thu Apr 24, 2008 8:14 am

Re: Adding custom fields

Post by myvo04 » Thu Apr 16, 2009 10:28 am

Thanks! That fixed the problem! I'm starting to work on the Order Source piece and will get back with you if I run into any problems.

myvo04
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 29
Joined: Thu Apr 24, 2008 8:14 am

Re: Adding custom fields

Post by myvo04 » Wed Apr 22, 2009 8:38 am

mazhar wrote:
the Order Source data is only valid with one specific order
Secondly regarding Order Source information one solution could be to make use of ac_CustomFields. Please read following thread about their use
viewtopic.php?f=42&t=8651
At what point in the checkout process is the order id actually assigned? I am new to C# and in trying to implement the code you suggested, but am receiving an "object set to null reference" error because there is no order id available from the checkout page...it's not available until after you complete checkout so how do I get the order source code (set on the first page of checkout) to store on the order?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Adding custom fields

Post by mazhar » Wed Apr 22, 2009 8:58 am

Imidiatily after placement of order the very first location where you can access orderid is Checkedout method of OnePageCheckout control. You can access order there as below

Code: Select all

Order order = OrderDataSource.Load(e.OrderId);
.............
.............

myvo04
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 29
Joined: Thu Apr 24, 2008 8:14 am

Re: Adding custom fields

Post by myvo04 » Thu Apr 23, 2009 11:42 am

Now I'm trying to take the industry code that was stored in the custom fields table and make it viewable on the ViewOrder.aspx page in the admin site. Do you have any example code I can refer to for this?

Post Reply