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 System;
using Dynamicweb.Ecommerce.Frontend;
using Dynamicweb.Ecommerce.Orders;
using Dynamicweb.Environment.Helpers;
using Dynamicweb.Rendering;
namespace Dynamicweb.Ecommerce.Examples.Orders;
public static 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 static void RenderCustomerOrders(Template template, int customerId, Dynamicweb.Frontend.PageView pageView, int paragraphId)
{
ArgumentNullException.ThrowIfNull(template, nameof(template));
ArgumentNullException.ThrowIfNull(pageView, nameof(pageView));
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
settingsCustomerCenterSettingsThe customer center settings.
orderTypeOrderTypeThe order type.
recurringOrderIdintThe 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
customerIdlongThe customer ID.
shopIdsstringThe shops IDs.
orderTypeOrderTypeThe order type.
useCustomerNumberboolSelect 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
customerIdlongThe customer ID.
shopIdsstringThe shops IDs.
orderTypeOrderTypeThe order type.
recurringOrderIdintThe recurring order ID.
useCustomerNumberboolSelect orders by user customer number.
orderContextIdsstringThe 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
customerIdlongThe customer ID.
shopIdsstringThe shops IDs.
orderTypeOrderTypeThe order type.
recurringOrderIdintThe recurring order ID.
useCustomerNumberboolSelect orders by user customer number.
orderContextIdsstringThe order context IDs.
fromDateDateTimeThe minimum order date.
LoadPendingOrders(long)
Loads customer unclosed orders from the database by specified customer ID.
public void LoadPendingOrders(long customerId)
Parameters
customerIdlongThe customer ID.
Examples
Look at example for CustomerOrderCollection class