Table of Contents

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 CustomerOrderCollection

The orders.

CustomerOrderCollectionFilter(ref CustomerOrderCollection, bool)

Initializes a new instance of the CustomerOrderCollectionFilter class.

public CustomerOrderCollectionFilter(ref CustomerOrderCollection orders, bool searchInCustomFields)

Parameters

orders CustomerOrderCollection

The orders.

searchInCustomFields bool

Search 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

bool

Methods

AddDateRangeFilter(DateTime, DateTime)

Adds the date range filter.

public void AddDateRangeFilter(DateTime fromDate, DateTime toDate)

Parameters

fromDate DateTime

From date.

toDate DateTime

To date.

Examples

Look at example for CustomerOrderCollectionFilter class

AddFreetextFilter(string)

Adds the free text filter.

public void AddFreetextFilter(string freeText)

Parameters

freeText string

The 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

fromAmount double

From amount.

toAmount double

To amount.

Examples

Look at example for CustomerOrderCollectionFilter class

AddProductFilter(ref string)

Adds the product filter.

public void AddProductFilter(ref string productId)

Parameters

productId string

The product ID.

Examples

Look at example for CustomerOrderCollectionFilter class

ApplyFromQueryString(int)

Applies filter from query string.

public void ApplyFromQueryString(int paragraphId)

Parameters

paragraphId int

The paragraph ID.

Examples

Look at example for CustomerOrderCollectionFilter class

To top