Evaluate customer's prior orders

The GetOrders() customer extension method has been around since Shipping Director 1.13 (for nopCommerce 3.10), but we've never blogged about it.  Here's a couple of possible scenarios  (you may need to put the expression in different configuration fields depending on your needs).

Example: Prior orders containing 2 or more products from a particular vendor:

  Customer.GetOrders().Count(OrderItems.Any(Product.VendorId = 1)) > 2

Example: 10% discount (by using Surcharge Expression) if any (paid) orders in the last 45 days

    Integer PaymentStatus_Paid 30
    Customer.GetOrders().Any(CreatedOnUtc > DateTime.UtcNow.AddDays(-45) and PaymentStatusId = [PaymentStatus_Paid]) ? -[$Rate]*0.10 : 0

Example: Free Shipping for Add On Order (i.e. there's a prior order that's not yet shipped)

    Integer ShippingStatus_NotYetShipped  20
    OptionExit   Free Shipping for Add On Order    Customer.GetOrders().Any(ShippingStatusId = [ShippingStatus_NotYetShipped])     0

Tags :  Expressions
Comments
Leave your comment
:
sample@email.tst
Created on: 6/26/2023 5:32 PM
1