Shipping Director 1.02 can Exclude Items from Packing

(This is an old blog.  If using nopCommerce 3.x or greater, note that "ProductVariant." should be removed if you copy these expressions)

You can exclude items from packing - the Packing option now has a "Exclude Item Expression" (shows in Description Expression column).  It should evaluate as a boolean (true, false).  Items that are not packed do not contribute to the weight/dimensions of a package, therefore you can create complex free shipping scenarios like "Free shipping for product x if quantity n or more".   Note that Packing expressions are always with respect to the item as it's being packed (unlike other record types where expressions relate to the entire cart - e.g. Items).  So, if you need to count the quantity of something in the cart to determine if exclusion should apply, then you need to do it with a variable before you pack.  Then, use that variable in the Exclude Item Expression with any other item specific expression.  For example, below, we sum the quantity of a particular item and if greater than 10, the "Exclude From Packing" variable is true.  Then in packing expression, we use the variable to check if exclusion should be considered, and then check the item condition.

Note also, that we initially check for Free Shipping - no point in checking expressions, packing, etc., if all items in cart are free shipping.  (An alternate, and better although a little slower, way to check free shipping for the entire cart is to use the $IsFreeShipping variable; this uses the nopC core OrderTotalCalcService.IsFreeShipping to check all the possible cart ships free possibilities including customer roles).  Also, we check variable $PackageCount after we pack - [$PackageCount is set by the system with the # of packages that result from packing - if nothing was packed (everything was excluded), then the entire cart ships free.

Order

Type

Name

Expression

Rate Expression

Surcharge Expression

Name Expression

Description Expression

10

OptionExit

Free Shipping

Items.All(ProductVariant.IsFreeShipping)

0

 

 

 

100

Reference

productName

ProductVariant.Product.Name

 

 

 

 

110

Boolean

Exclude From Packing

Items.Where([@productName] = "my product name").Sum(Quantity) > 10

 

 

 

 

120

Packing

First Fit

true

Packing.FirstFitSingleBox

 

 

[Exclude From Packing] and [@productName] = "my product name"

130

OptionExit

Free Shipping

[$PackageCount] = 0

0

 

 

 

Tags :  Packing
Comments
Leave your comment
: