Class CustomerOrderCollection
- Namespace
- Dynamicweb.Ecommerce.Orders
- Assembly
- Dynamicweb.Ecommerce.dll
Represents a collection of customer orders
[Serializable]
public class CustomerOrderCollection : Collection<Order>, IList<Order>, ICollection<Order>, IReadOnlyList<Order>, IReadOnlyCollection<Order>, IEnumerable<Order>, IList, ICollection, IEnumerable
- Inheritance
-
Customer
Order Collection
- Implements
- Inherited Members
- Extension Methods
Examples
using Dynamicweb.Core.Helpers;
using Dynamicweb.Ecommerce.Frontend;
using Dynamicweb.Ecommerce.Orders;
using Dynamicweb.Environment.Helpers;
using Dynamicweb.Rendering;
using System;
namespace Dynamicweb.Ecommerce.Examples.Orders
{
public class CustomerOrdersRendererSample
{
private struct Tags
{
public const string LoopStartOrders = "LoopStart(Orders)";
public const string OrderCount = "Ecom:CustomerCenter.Orders.Count";
public const string EmptyOrderList = "Ecom:CustomerCenter.Orders.EmptyList";
public const string LoopOrders = "Orders";
public const string Reorder = "Ecom:Order.ReorderID";
}
public void RenderCustomerOrders(Template template, int customerId, Dynamicweb.Frontend.PageView pageView, int paragraphId)
{
if (template.LoopExists(Tags.LoopStartOrders))
{
CustomerOrderCollection customerOrders = new CustomerOrderCollection();
customerOrders.Load(customerId, string.Empty, 0, false);
// Add filtering
CustomerOrderCollectionFilter filter = new CustomerOrderCollectionFilter(ref customerOrders);
filter.ApplyFromQueryString(paragraphId);
CustomerOrderCollection ordersToRender = filter.Output;
template.SetTag(Tags.OrderCount, ordersToRender.Count);
if (ordersToRender.Count == 0)
{
template.SetTag(Tags.EmptyOrderList, "true");
}
else
{
Template orderTemplate = template.GetLoop(Tags.LoopOrders);
Renderer renderer = new Renderer(pageView);
// Create querystrings common to add all products in the order to the cart command
string rawQString = LinkHelper.StripQueryString("CC" + paragraphId + ",ReorderID" + paragraphId + ",ResendOrderID" + paragraphId + ",Addresses" + paragraphId + ",CCAddToMyLists" + paragraphId + "*,CCRemoveFromMyLists" + paragraphId + "*");
string reorderQString = LinkHelper.AddToQueryString(rawQString, "CC" + paragraphId + "=Orders");
foreach (Order order in ordersToRender)
{
// Adds all products in the order to the cart
orderTemplate.SetTag(Tags.Reorder, LinkHelper.AddToQueryString(reorderQString, "ReorderID=" + order.Id));
renderer.RenderOrder(order, orderTemplate);
orderTemplate.CommitLoop();
}
}
}
}
}
}
Fields
OrderContextEmpty
Field Value
Properties
GetUniqueProducts
Gets the array of unique products.
Property Value
- IEnumerable<Unique
Product > The unique products.
MaxDate
Find the max date of order.
Property Value
- Date
Time The max date.
MinDate
Find the min date of order.
Property Value
- Date
Time The min date.
Methods
Load(CustomerCenterSettings, OrderType, int)
Loads customer orders of specified type
Parameters
settings
CustomerCenter Settings The customer center settings.
orderType
OrderType The order type.
recurringOrderId
intThe recurring order ID.
Load(long, string, OrderType, bool)
Loads customer orders of specified type
Parameters
customerId
longThe customer ID.
shopIds
stringThe shops IDs.
orderType
OrderType The order type.
useCustomerNumber
boolSelect orders by user customer number.
Load(long, string, OrderType, int, bool, string)
Loads customer orders of specified type
public void Load(long customerId, string shopIds, OrderType orderType, int recurringOrderId, bool useCustomerNumber, string orderContextIds)
Parameters
customerId
longThe customer ID.
shopIds
stringThe shops IDs.
orderType
OrderType The order type.
recurringOrderId
intThe recurring order ID.
useCustomerNumber
boolSelect orders by user customer number.
orderContextIds
stringThe order context IDs.
Load(long, string, OrderType, int, bool, string, DateTime)
Loads customer orders of specified type
public void Load(long customerId, string shopIds, OrderType orderType, int recurringOrderId, bool useCustomerNumber, string orderContextIds, DateTime fromDate)
Parameters
customerId
longThe customer ID.
shopIds
stringThe shops IDs.
orderType
OrderType The order type.
recurringOrderId
intThe recurring order ID.
useCustomerNumber
boolSelect orders by user customer number.
orderContextIds
stringThe order context IDs.
fromDate
DateTime The minimum order date.
LoadPendingOrders(long)
Loads customer unclosed orders from the database by specified customer ID.
Parameters
customerId
longThe customer ID.
Examples
Look at example for CustomerOrderCollection
class