Blog posts of '2012' 'December'

RSS
Simple Free Shipping based on Role- Tuesday, December 18, 2012

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 (2)
Shipping Discount - use a negative surcharge- Friday, December 14, 2012

Similar to adding an insurance surchargeto the shipping rate, one can provide a discount just by making the surcharge a negative amount.

In this example, we’ll use the “Shipping by weight” calculator for shipping, and set a discount of $2.99 if the cart’s total is $20 or more.

Order

Type

Name

Expression

Rate Expression

Surcharge Expression

10

Option

Shipping

true

Shipping.ByWeight

([$SubTotalWithDiscounts] > 20) ? -2.99 : 0

As mentioned in prior blogs, the " ? : " is the ternary if-then-else operator.  These can be chained together if needed - for example to have discounts based on amount like this:

Subtotal greater than

Discount

100

7.99

50

5.99

20

2.99


Then the expression would look like

  ([$SubTotalWithDiscounts] > 100) ? -7.99 :  ([$SubTotalWithDiscounts] > 50) ? -5.99 :  ([$SubTotalWithDiscounts] > 20) ? -2.99 : 0

Tags :  Discount
Comments (1)
$5 Ground for orders over $50 except Alaska & Hawaii- Sunday, December 9, 2012

Another simple example of having a reduced Ground shipping rate

Basically, you use the Surcharge to negate the Ground Rate and then add $5.   In this example, we do it for USPS.  (Read more about using Surcharge to adjust the rate here)

Order

Type

Name

Expression

Rate Expression

Surcharge Expression

100

Packing

Pack

true

Packing.FirstFitSingleBox

 

110

Option

USPS

true

Shipping.USPS

([$SubTotalWithDiscounts] > 50) AND !("AK,HI".Contains([State]) AND [$Name].Contains("Ground")) ? -[$Rate] + 5 : 0

For the most accurate carrier rates, set your package size - see this blog about packing 

Tags :  FreeShipping
Comments (0)
Free Shipping over ‘X’ but still charge “Additional Shipping Charges”- Friday, December 7, 2012

If you want to use Free Shipping over ‘X’ but still charge “Additional Shipping Charges”, you can't use nopC’s built-in Admin > Configuration > Settings > Shipping >> "Free Shipping over 'X'" because it will ignore Additional Shipping Charges set on product variants.  The built-in Free Shipping over ‘X’ is always calculated last after shipping plugins return their options.   You can make this work with Shipping Director.  First, be sure to turn off "Free Shipping over 'X' " in admin.  (And as always when using SD, be sure that SD is the only Active rate calc method.)

This is really easy to do in SD – just calculate a 0 rate when the subtotal is over X!  Then, NopC will always add the additional shipping charges.  For example, here’s free shipping ($0) if the subtotal is more than $50:

Order

Type

Name

Expression

Rate Expression

10

OptionExit

Shipping

[$SubTotalWithDiscounts] >= 50

0

 

Of course, to make this complete, we'll add the second Option record to provide the rate if the cart does not meet the minimum amount.  And, to get a little fancy, we’ll use the Name Expression to show the customer “Free Shipping” if none of the items have any additional shipping charges, otherwise show “Shipping”:

Order

Type

Name

Expression

Rate Expression

Name Expression

10

OptionExit

Shipping

[$SubTotalWithDiscounts] >= 50

0

Items.Any(Product.AdditionalShippingCharge > 0) ? "Shipping" : "Free Shipping"

20

Option

Shipping

true

5

 

The second record above is a flat $5 rate, but you can of course use any type and number of additional methods/rates instead.

(P.S.  updated on July 2014 - ProductVariant -> Product)

Tags :  FreeShipping
Comments (0)
Shipping Director 1.07 available for NopCommerce 2.70 and 2.65- Wednesday, December 5, 2012
Here are the new features (I'll blog about them in more detail soon :)

SortExpression setting
  An optional sort of the options after all records have been processed.
  You can sort the options by any expression involving the shipping option fields: Rate, Name, Description

Query Expression support for First(), FirstOrDefault() and Select()
  e.g. Instead of saying Items.Where(...).First(), you can just say Items.First(...)

More Extension functions:
  String
    Split(separator)
    IsNumeric()
    IsInteger()
  ShoppingCartItem
    GetAttributeValues(attributeName, valueSeparator)
    GetAttributeValues(attributeName)
    HasAttributeValue(attributeName, valueName)
    HasAttributeValue(attributeName)
    HasAttributeValue(valueId)
  Product
    HasCategory(categoryName) 
    HasCategory(categoryId) 
    HasCategoryMatch(categoryNameRegex)
  
Test
  A store owner or developer can test their shipping calculations in the configuration page.  Testing here is not limited to the 5 transaction limit in trial/evaluation mode.
  You can select a customer to use test cart/address. (You must take that test customer through checkout process to the point of shipping address selection for that address to be stored with customer.)

Export tab delimited
Import tab delimited 
  Export/Import is not only great for backup and migrations, but also allows store owner to use different shipping scenarios with ease.
  Additionally, you can work in Excel where data entry can be easier for advanced users - just save as "Text (tab delimited)".

Tags :  1.07
Comments (1)