More Complex Free Shipping Scenario

This is a more complex free shipping scenario that involves multiple free shipping methods (Fedex Ground & Standard), and also a "$5 Next Day Shipping".  So, some items can get Free Ground, other items can get Free Next Day, and other items can get $5 Next Day.  I won't go into too much detail about how this one works, so you should read the prior blog to understand the idea of packing for free shipping, and the multiple Option type records.  I know it looks a little daunting.  In the future I hope to provide a simpler interface, or the nopCommerce core will support product level shipping configuration.

Similar to last blog, separate Categories are used to pidgeonhole the products.  Note the Reference variable hasReducedNextDayShipping;  this covers both free next day and $5 next day.   The Fedex Name for standard next day is "FedEx Standard Overnight".   The idea is to first use Option(FedEx) to get the rates for all the products, then Pack/OptionReplace to get (replace) the rates for non-reduced items.  Finally, add in rate for $5 Next day items.

Note the new Packing method "Packing.ClearPackages".  This restores the original "single package" which is the default state prior to any other packing methods being used.  This is necessary because the Option record type with a  Rate Expression that is not a shipping method like Shipping.Fedex applies the Rate Expression for each package; we just want one package because we calculate variable "Number of $5 NextDay Items" based on sum of item quantities.  Then the last Option type record adds the appropriate number of $5 per item charges to the "FedEx Standard Overnight" rate (after it's been previously calculated by Fedex for the non-reduced next day items if any).

EvalType

Name

Expression

RateExpression

NameExpression

DescriptionExpression

Reference

HasCategory

ProductVariant.Product.ProductCategories.Any

 

 

 

Reference

hasReducedGroundShipping

[@HasCategory]
(Category.Name.Contains("Ground Shipping"))

 

 

 

Reference

hasReducedNextDayShipping

[@HasCategory]
(Category.Name.Contains("Next Day Shipping"))

 

 

 

Reference

has5$NextDayShipping

[@HasCategory]
(Category.Name = "$5 Next Day Shipping")

 

 

 

Integer

Number of $5 NextDay Items

Items.Where
([@has5$NextDayShipping]).Sum(Quantity)

 

 

 

Option

FedEx All Items

true

Shipping.Fedex

 

 

Packing

Pack exclude reduced-ground items

Items.Any([@hasReducedGroundShipping])

Packing.FirstFitSingleBox

 

[@hasReducedGroundShipping]

OptionReplace

FedEx Ground Only

Items.Any([@hasReducedGroundShipping])

Shipping.Fedex

[$Name].Contains("Ground")
 ? [$Name] : ""

 

Packing

Pack exclude
reduced-nextday items

Items.Any([@hasReducedNextDayShipping])

Packing.FirstFitSingleBox


[@hasReducedNextDayShipping]

OptionReplace

FedEx NextDay Only

Items.Any([@hasReducedNextDayShipping])

Shipping.Fedex

[$Name].Contains("Standard")
 ? [$Name] : ""

 

Packing

Clear Packages For Fixed Rates

true

Packing.ClearPackages

 

 

Option

$5 NextDay

Items.Any([@has5$NextDayShipping])

[Number of $5 NextDay Items] * 5.00

"FedEx Standard Overnight"

 

Tags :  FreeShipping
Comments
Leave your comment
:
vamsianilm@mindfiresolutions.com
Created on: 11/3/2014 6:10 AM
How can I implement ShippingDirector based on specific Category? If Cart is filled with Category_A only and is Ground shipping, then no shipping charges. If cart if filled with other Categories, then shipping charges to be added.
support@nopTools.com
Created on: 11/3/2014 7:50 PM
Just two records:

Type: Boolean
Name: FreeGround
Expression: Items.All(Product.HasCategory("CategoryA"))


Type: Option
Name: Shipping
Expression: true
Rate Expression: Shipping.FedEx
Surcharge Expression: [FreeGround] and [$Name].Contains("Ground") ? -[$Rate] : 0


If you're using UPS rather than FedEx, then use Shipping.UPS in the Rate Expression