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 |
Fast Shipping ($10.00) |
And if she's not in that role she sees
Select shipping method |
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 |
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.