You typically add properties to the COM orderform object through the OrderPipelineMappings file in your solution. The file provided with the starter site has the following properties:
<!--Following properties in this map are in the OrderForm where as in the object model these properties reside in the OrderGroup class. This is an exceptional case for these three properties. This kind of mapping is not allowed for other properties.-->
<Property Name="TrackingNumber" DictionaryKey="order_number" />
<Property Name="SoldToId" DictionaryKey="user_id" />
<Collection Name="Addresses" DictionaryKey="Addresses" KeyType="Dictionary" ReferTo="OrderAddress" />
As such, you wont be able to use all of the properties from your purchase order / basket object, but the property you're looking for should be "user_id".
As you've probably noted, the rest of the OrderGroup values are inaccessible in the pipeline.
You can either use the email address in the address dictionary, or you can attach the value in the ordergroup field to the context dictionary prior to running the pipeline.
IE:
PipelineInfo p = new PipelineInfo();
p["sold_to_name"] = bas["sold_to_name"];
That only takes care of reading from this value, and I know of no clever tricks for writing to this value in the pipeline. I'll reiterate that the pipelines operate at the orderform level, and the product team worte very specific logic to capure the aforementioned three values at that level, so I'm not sure how difficult it would be to add another value (It specifically says in that mapping file that this kind of mapping is not allowed for other properties).
I believe the context dictionary is passed in as the second parameter to the execute method within a pipeline component (have a look at the method signature).
You should be able to cast it as a dictionary and work with it the exact same way you work with the OrderForm.
Joseph is correct if you need a sample of how this is done look at my blog:
Everything you ever wanted to know about pipelines but were afraid to ask (Part III)
Here is a sample code (from ASP.NET):
Basket basket = CommerceContext.Current.OrderSystem.GetBasket(userID);
PipelineInfo pipeinfo = new PipelineInfo("Basket");
pipeinfo["OrderContext"] = CommerceContext.Current.OrderSystem;
basket.RunPipeline(pipeinfo);
Code inside your pipeline:
public int Execute(object pdispOrder, object pdispContext, int lFlags)
{
Int32 ReturnValue = StatusSuccess;
// How to get our Custom OrderContext
IDictionary Context = (IDictionary)pdispContext;
OrderContext myOrderContext = (OrderContext)Context["OrderContext"];
// How to get MessageManager Context
IMessageManager MessageManager = (IMessageManager)Context["MessageManager"];
// do some work here...
return ReturnValue;
}
The quick and dirty way in my mind is to pump it into the order form and pull the value out in the pipeline. You can either do it before RunPipeline or if you use an extended Basket object you can override the RunPipline method:
public override PipelineExecutionResult RunPipeline(PipelineInfo pipelineInfo, PipelineBase pipeline)
{
// Propogate OrderGroup items down to the OrderForm level.
foreach (OrderForm orderForm in this.OrderForms)
{
orderForm[OrderForm.Keys.StoreName] = this.storeName;
orderForm[OrderForm.Keys.UserComments] = this.userComments;
orderForm[OrderForm.Keys.UserFirstName] = this.userFirstName;
orderForm[OrderForm.Keys.UserLastName] = this.userLastName;
orderForm[OrderForm.Keys.UserEmailAddress] = this.userEmailAddress;
orderForm[OrderForm.Keys.UserIpAddress] = this.userIpAddress;
orderForm[OrderForm.Keys.UserBrowserAgent] = this.userBrowserAgent;
orderForm[OrderForm.Keys.UserHostName] = this.userHostName;
orderForm[OrderForm.Keys.UserLocale] = this.userLocale;
orderForm[OrderForm.Keys.ExchangeRate] = new CurrencyWrapper(this.exchangeRate);
orderForm[OrderForm.Keys.BillingCurrency] = this.BillingCurrency;
}
PipelineExecutionResult ReturnValue;
if (pipeline == null)
{
ReturnValue = base.RunPipeline(pipelineInfo);
}
else
{
ReturnValue = base.RunPipeline(pipelineInfo, pipeline);
}
// Promote OrderForm items up to the OrderGroup.
if (this.OrderForms.Count > 0)
{
decimal decimalValue;
if (Helper.TryCast<decimal>(this.OrderForms[OrderForm.DefaultOrderFormName][OrderForm.Keys.ExchangeRate], out decimalValue))
{
this.exchangeRate = decimalValue;
}
}
return ReturnValue;
}
We've done this to "promote" additional Order Group level properties to the pipeline when we need it.
Then in your pipeline code you can access the property and pull a value out. Check out my latest blog post with an example of how to access the order form and pipeline context using a strongly-typed wrapper as well.
Cheers,
Colin