Sometimes You Have to Write Some Code!

That’s right. You heard me. Sometimes you have to roll up your sleeves and write some code. Even using Commerce Server 2007!

I’ve been pretty amazed how full featured and complete Commerce Server 2007 is and how little custom code I had to write to get my e-commerce site up and running. But every once in a while I run into a scenario that the product just doesn’t cover very well. One such “pain point” is how to display a list of a user’s or organization’s shipping addresses without including the billing address.

In our B2B scenario the customer’s billing address and customer ID “define” the customer in the back-end ERP system. This means we really don’t want to allow the customer to edit this address on the site, but we DO want to allow the customer to add, change and delete his shipping addresses. The Commerce Server Profiles subsystem doesn’t cover this scenario as none of the standard methods will return only the shipping addresses.

So we dug under the covers (a little) and wrote a simple method which returns a DataSet containing only shipping addresses from the <sitename>_profiles database.

Nothing fancy, just some C# code which calls a stored procedure as shown below. The “magic” is in setting up the Address profiles including the Address Type.

The result is a standard DataSet which can be bound to any number of ASP.NET server controls such as the GridView shown here.

The C# code resides in a helper class in the site’s App_Code folder and the custom stored procedure resides in the <sitename>_profiles database. Typical ASP.NET 2.0 stuff applied to a scenario Commerce Server just doesn’t cover (at least not yet).

Take Away: Not all your e-commerce needs will be covered by the subsystems included with Commerce Server 2007, but combined with C#, T-SQL and ASP.NET 2.0 there’s almost nothing you can’t create! Use Your Imagination…

Technorati Tags: Commerce Server

Share this post: Email it! | bookmark it! | digg it! | reddit!| kick it!