Simple Free Shipping based on Role

Here's a very simple free shipping scenario with fixed rates.  Customers in the "Free Shipping" role get an option for free shipping ($0).  If not in that role, they see regular shipping.  (The leading "!" is the NOT operator.)   Everybody sees an option for "Fast Shipping".  

(Update: 12/20/2021 - Customer.CustomerRoles won't work in 4.x and above.   Use Customer.GetCustomerRoles() to get the full collection, or to check a specific role, use helper property  Customer.IsInRole("role system name").  The below has been modified to use Customer.IsInRole() )

Order

Type

Name

Expression

Rate Expression

10

Option

Free Shipping

Customer.IsInRole("Free Shipping")

0

20

Option

Regular Shipping

!Customer.IsInRole("Free Shipping")

5

30

Option

Fast Shipping

true

10

 

So, if the customer is in the Free Shipping role, then she sees

Select shipping method
 Free Shipping ($0.00)
 Fast Shipping ($10.00)

And if she's not in that role she sees

Select shipping method
 Regular Shipping ($5.00)
 Fast Shipping ($10.00)

 

You can always add additional criteria.   If there are a lot of criteria, then create a variable to make it easier to read and maintain.  For example, let's also have additional criteria that the cart subtotal must be greater than $250

Order

Type

Name

Expression

Rate Expression

5

Boolean

HasFreeShipping

Customer.IsInRole("Free Shipping") and [$SubTotalWithDiscounts] > 250

 

10

Option

Free Shipping

[HasFreeShipping]

0

20

Option

Regular Shipping

![HasFreeShipping]

5

30

Option

Fast Shipping

true

10

 


Tags :  FreeShipping
Comments
Leave your comment
:
anai.heath@sunriseid.com
Created on: 6/11/2018 2:51 PM
How can I express free shipping based on customer role and additionally limited to zip code (98109)?
support@nopTools.com
Created on: 6/11/2018 11:39 PM
The Expression field evaluates the condition and if true it will be shown to customer.  Use Customer.IsInRole() to check a role:

IsInRole(roleSystemName)

(or  IsInCustomerRole(roleSystemName)  )

Be sure to assign the Role's "System name" field.  If you need to do a wildcard match, use e.g.  Customer.CustomerRoles.Any(SystemName.Contains("Discount"))

see for more info: https://www.noptools.com/blog/60/expressions-can-use-extension-methods


For example, FedEx for everyone (Expression is 'true'), and Free Ship only for customers in role "Free Shipping" and Zip 98109.


Option    Free Shipping  Customer.IsInRole("Free Shipping") and Zip = " 98109 "     0.00

Option    FedEx          true                                                                                   Shipping.FedEx


Be sure to assign the Role's "System name" field, and use that in the IsInRole function.