(Updated 11/29/2013 for Shipping Director versions for nopCommerce 3.x)
For external shipping rate methods (carrier plugins like FedEx, USPS, etc.), which can return many options, it may be desirable to conditionally eliminate some options.
In this example, we only offer USPS Media Mail if all items in the cart are books:
Order | Type | Name | Expression | Rate Expression | Name Expression |
10 | Boolean | CategoriesAllBooks | Items.All(Product.HasCategory("Books")) |
|
|
100 | Option | USPS | true | Shipping.USPS | [$Name].Contains("Media Mail") and ![CategoriesAllBooks] ? "" : [$Name] |
Of course you're not limited to checking Categories. For example, you could also eliminate an option based on there being any item in the cart with the Product Name Length greater than X. E.g.
Items.Any(ProductVariant.Product.Name.Length > 12)
_________________________________________________________________________________________________
Here's the old version for nopC 2.x having Product Variants, and prior to SD having HasCategory() function:
Order | Type | Name | Expression | Rate Expression | Name Expression |
10 | Reference | categories | ProductVariant.Product.ProductCategories |
|
|
20 | Boolean | categoriesAllBooks | Items.All([@categories].Any(Category.Name = "Books")) |
|
|
100 | Option | USPS | true | Shipping.USPS | [$Name].Contains("Media Mail") and ![categoriesAllBooks] ? "" : [$Name] |