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
-
CustomerOrderCollection
- 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
public const string OrderContextEmpty = "-1"
Field Value
Properties
GetUniqueProducts
Gets the array of unique products.
public IEnumerable<UniqueProduct> GetUniqueProducts { get; }
Property Value
- IEnumerable<UniqueProduct>
The unique products.
MaxDate
Find the max date of order.
public DateTime MaxDate { get; }
Property Value
- DateTime
The max date.
MinDate
Find the min date of order.
public DateTime MinDate { get; }
Property Value
- DateTime
The min date.
Methods
Load(CustomerCenterSettings, OrderType, int)
Loads customer orders of specified type
public void Load(CustomerCenterSettings settings, OrderType orderType, int recurringOrderId)
Parameters
settings
CustomerCenterSettingsThe customer center settings.
orderType
OrderTypeThe order type.
recurringOrderId
intThe recurring order ID.
Load(long, string, OrderType, bool)
Loads customer orders of specified type
public void Load(long customerId, string shopIds, OrderType orderType, bool useCustomerNumber)
Parameters
customerId
longThe customer ID.
shopIds
stringThe shops IDs.
orderType
OrderTypeThe 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
OrderTypeThe 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
OrderTypeThe order type.
recurringOrderId
intThe recurring order ID.
useCustomerNumber
boolSelect orders by user customer number.
orderContextIds
stringThe order context IDs.
fromDate
DateTimeThe minimum order date.
LoadPendingOrders(long)
Loads customer unclosed orders from the database by specified customer ID.
public void LoadPendingOrders(long customerId)
Parameters
customerId
longThe customer ID.
Examples
Look at example for CustomerOrderCollection
class