Class CustomerOrderCollectionFilter
- Namespace
- Dynamicweb.Ecommerce.Orders
- Assembly
- Dynamicweb.Ecommerce.dll
The class CustomerOrderCollectionFilter represents a filter of a collection of customer orders.
[Serializable]
public class CustomerOrderCollectionFilter
- Inheritance
-
CustomerOrderCollectionFilter
- Inherited Members
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();
}
}
}
}
}
}
Constructors
CustomerOrderCollectionFilter(ref CustomerOrderCollection)
Initializes a new instance of the CustomerOrderCollectionFilter class.
public CustomerOrderCollectionFilter(ref CustomerOrderCollection orders)
Parameters
orders
CustomerOrderCollectionThe orders.
CustomerOrderCollectionFilter(ref CustomerOrderCollection, bool)
Initializes a new instance of the CustomerOrderCollectionFilter class.
public CustomerOrderCollectionFilter(ref CustomerOrderCollection orders, bool searchInCustomFields)
Parameters
orders
CustomerOrderCollectionThe orders.
searchInCustomFields
boolSearch in the order custom fields.
Properties
Output
Gets the filtered collection of customer orders.
public CustomerOrderCollection Output { get; }
Property Value
- CustomerOrderCollection
The output.
SearchInCustomOrderFields
Determines whether filter should do search in the custom order fields.
public bool SearchInCustomOrderFields { get; set; }
Property Value
Methods
AddDateRangeFilter(DateTime, DateTime)
Adds the date range filter.
public void AddDateRangeFilter(DateTime fromDate, DateTime toDate)
Parameters
Examples
Look at example for CustomerOrderCollectionFilter
class
AddFreetextFilter(string)
Adds the free text filter.
public void AddFreetextFilter(string freeText)
Parameters
freeText
stringThe free text.
Examples
Look at example for CustomerOrderCollectionFilter
class
AddPriceRangeFilter(double, double)
Adds the price range filter.
public void AddPriceRangeFilter(double fromAmount, double toAmount)
Parameters
Examples
Look at example for CustomerOrderCollectionFilter
class
AddProductFilter(ref string)
Adds the product filter.
public void AddProductFilter(ref string productId)
Parameters
productId
stringThe product ID.
Examples
Look at example for CustomerOrderCollectionFilter
class
ApplyFromQueryString(int)
Applies filter from query string.
public void ApplyFromQueryString(int paragraphId)
Parameters
paragraphId
intThe paragraph ID.
Examples
Look at example for CustomerOrderCollectionFilter
class