Add an order dropdown to Forms

I wanted an adjustable contact form with a dropdown containing the order numbers of the current user. With a custom data feed this is very easy accomplished within the forms module. See this post for more information about data feeds.

For the LoadItems implementation you can use the following:

public IEnumerable<IFeedItem> LoadItems()
{
   IEnumerable<IPurchaseOrder> orders = this.orderRepository.Load<IPurchaseOrder>();
   return orders.Select(order =>
      new FeedItem { Key = order.OrderNumber, Value = order.OrderNumber })
                .Cast<IFeedItem>()
                .ToList();
}

Now you will be able to select orders as a datafeed for a dropdown. And the customer can select the order number they want information about.

For the full data feed code see this gist

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s