Skip to content

Commit 8111ce0

Browse files
committed
smartstore#280 Filter orders by customer name
1 parent be21d85 commit 8111ce0

6 files changed

Lines changed: 35 additions & 8 deletions

File tree

src/Libraries/SmartStore.Services/Orders/IOrderService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ public partial interface IOrderService
6666
/// <param name="orderGuid">Search by order GUID (Global unique identifier) or part of GUID. Leave empty to load all records.</param>
6767
/// <param name="pageIndex">Page index</param>
6868
/// <param name="pageSize">Page size</param>
69+
/// <param name="billingName">Billing name. Leave empty to load all records.</param>
6970
/// <returns>Order collection</returns>
7071
IPagedList<Order> SearchOrders(int storeId, int customerId,
71-
DateTime? startTime, DateTime? endTime,
72-
OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss,
73-
string billingEmail, string orderGuid, string orderNumber, int pageIndex, int pageSize);
72+
DateTime? startTime, DateTime? endTime, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss,
73+
string billingName, string orderGuid, string orderNumber, int pageIndex, int pageSize, string billingEmail = null);
7474

7575
/// <summary>
7676
/// Gets all orders by affiliate identifier

src/Libraries/SmartStore.Services/Orders/OrderService.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ public virtual void DeleteOrder(Order order)
171171
/// <param name="orderGuid">Search by order GUID (Global unique identifier) or part of GUID. Leave empty to load all orders.</param>
172172
/// <param name="pageIndex">Page index</param>
173173
/// <param name="pageSize">Page size</param>
174+
/// <param name="billingName">Billing name. Leave empty to load all records.</param>
174175
/// <returns>Order collection</returns>
175176
public virtual IPagedList<Order> SearchOrders(int storeId, int customerId,
176-
DateTime? startTime, DateTime? endTime,
177-
OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss,
178-
string billingEmail, string orderGuid, string orderNumber, int pageIndex, int pageSize)
177+
DateTime? startTime, DateTime? endTime, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss,
178+
string billingEmail, string orderGuid, string orderNumber, int pageIndex, int pageSize, string billingName = null)
179179
{
180180
int? orderStatusId = null;
181181
if (os.HasValue)
@@ -206,6 +206,11 @@ public virtual IPagedList<Order> SearchOrders(int storeId, int customerId,
206206
query = query.Where(o => shippingStatusId.Value == o.ShippingStatusId);
207207
if (!String.IsNullOrEmpty(billingEmail))
208208
query = query.Where(o => o.BillingAddress != null && !String.IsNullOrEmpty(o.BillingAddress.Email) && o.BillingAddress.Email.Contains(billingEmail));
209+
if (billingName.HasValue())
210+
query = query.Where(o => o.BillingAddress != null && (
211+
(!String.IsNullOrEmpty(o.BillingAddress.LastName) && o.BillingAddress.LastName.Contains(billingName)) ||
212+
(!String.IsNullOrEmpty(o.BillingAddress.FirstName) && o.BillingAddress.FirstName.Contains(billingName))
213+
));
209214
if (orderNumber.HasValue())
210215
query = query.Where(o => o.OrderNumber.ToLower().Contains(orderNumber.ToLower()));
211216
query = query.Where(o => !o.Deleted);

src/Presentation/SmartStore.Web/Administration/Controllers/OrderController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,8 @@ public ActionResult OrderList(GridCommand command, OrderListModel model)
686686

687687
//load orders
688688
var orders = _orderService.SearchOrders(model.StoreId, 0, startDateValue, endDateValue, orderStatus,
689-
paymentStatus, shippingStatus, model.CustomerEmail, model.OrderGuid, model.OrderNumber, command.Page - 1, command.PageSize);
689+
paymentStatus, shippingStatus, model.CustomerEmail, model.OrderGuid, model.OrderNumber, command.Page - 1, command.PageSize, model.CustomerName);
690+
690691
var gridModel = new GridModel<OrderModel>
691692
{
692693
Data = orders.Select(x =>

src/Presentation/SmartStore.Web/Administration/Models/Orders/OrderListModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public OrderListModel()
2727
[AllowHtml]
2828
public string CustomerEmail { get; set; }
2929

30+
[SmartResourceDisplayName("Admin.Orders.List.CustomerName")]
31+
public string CustomerName { get; set; }
32+
3033
[SmartResourceDisplayName("Admin.Orders.List.OrderStatus")]
3134
public int OrderStatusId { get; set; }
3235
[SmartResourceDisplayName("Admin.Orders.List.PaymentStatus")]

src/Presentation/SmartStore.Web/Administration/Views/Order/List.cshtml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
@Html.EditorFor(model => Model.CustomerEmail)
5050
</td>
5151
</tr>
52+
<tr>
53+
<td class="adminTitle">
54+
@Html.SmartLabelFor(model => model.CustomerName)
55+
</td>
56+
<td class="adminData">
57+
@Html.EditorFor(model => Model.CustomerName)
58+
</td>
59+
</tr>
5260
<tr>
5361
<td class="adminTitle">
5462
@Html.SmartLabelFor(model => model.OrderStatusId)
@@ -238,7 +246,8 @@
238246
var searchModel = {
239247
StartDate: $('#@Html.FieldIdFor(model => model.StartDate)').val(),
240248
EndDate: $('#@Html.FieldIdFor(model => model.EndDate)').val(),
241-
CustomerEmail: $('#@Html.FieldIdFor(model => model.CustomerEmail)').val(),
249+
CustomerEmail: $('#@Html.FieldIdFor(model => model.CustomerEmail)').val(),
250+
CustomerName: $('#@Html.FieldIdFor(model => model.CustomerName)').val(),
242251
OrderStatusId: $('#@Html.FieldIdFor(model => model.OrderStatusId)').val(),
243252
PaymentStatusId: $('#@Html.FieldIdFor(model => model.PaymentStatusId)').val(),
244253
ShippingStatusId: $('#@Html.FieldIdFor(model => model.ShippingStatusId)').val(),

src/Presentation/SmartStore.Web/App_Data/Migrations/1.2.1-1.3.0/1-migrate-resources.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,15 @@ SET @resources='
291291
<Value>The quantity value must be greater or equal to 1.</Value>
292292
<Value lang="de">Der Mengenwert muss größer oder gleich 1 sein.</Value>
293293
</LocaleResource>
294+
295+
<LocaleResource Name="Admin.Orders.List.CustomerName">
296+
<Value>Customer name</Value>
297+
<Value lang="de">Kundenname</Value>
298+
</LocaleResource>
299+
<LocaleResource Name="Admin.Orders.List.CustomerName.Hint">
300+
<Value>Filter order list by customer name.</Value>
301+
<Value lang="de">Auftragsliste nach dem Kundennamen filtern.</Value>
302+
</LocaleResource>
294303
295304
</Language>
296305
'

0 commit comments

Comments
 (0)