Maybe you're a small local store or restaurant, or pizza place; you want to offer local pickup at one of your two locations, or you will deliver nearby. Here's an example using State, but could also check ShippingAddress.ZipPostalCode or ShippingAddress.City
Order | Active | Type | Name | Expression | Rate Expression | Surcharge Expression | Name Expression | Description Expression |
10 |
| ErrorExit | No State Entered | ShippingAddress.StateProvince = null |
|
|
| "Please enter Country, State, and Zip" |
20 |
| ErrorExit | No Zip Entered | ShippingAddress.ZipPostalCode = null |
|
|
| "Please enter Country, State, and Zip" |
50 |
| String | ShippingState | ShippingAddress.StateProvince.Name |
|
|
|
|
100 |
| Option | In Store A Pickup | true | 0 |
|
|
|
110 |
| Option | In Store B Pickup | true | 0 |
|
|
|
200 |
| OptionExit | Local Delvery | [ShippingState] = "local 1" | 10 |
|
|
|
210 |
| OptionExit | Local Delivery | [ShippingState] = "local 2" | 20 |
|
|
|
300 |
| ErrorExit | Out of Area |
|
|
|
| "Sorry, we can’t deliver to that area" |
Also, this example shows fixed Rates, but you can also calculate some percentage of the cost, or fixed rate plus percentage, etc. using
[$SubTotalWithoutDiscounts]
[$SubTotalWithDiscounts]e.g. Rate = 5 + ( [$SubTotalWithDiscounts] * 0.05 )
(Note that only US and Canada have StateProvince configured by default in nopCommerce, so adjust/remove the above ErrorExit if needed)
I have a question.
Where does the local 1 come from in this sentence "[ShippingState] = "local 1" "
René
It's just a example, fictitious, state. You'll want to use one of state/province names that a customer would be able to select in the dropdown.
Boolean | IsLocalZip | ShippingAddress.ZipPostalCode = "33744" or ShippingAddress.ZipPostalCode = "33707"
Option | [IsLocalZip] and [Meal Count] > 0
this works with up to 125 zips, but errors out for anything more than that. is there a simpler way to write this as either a Boolean or a string for the Boolean?
You can use "33744,33707,...".Contains(Zip)
However, you may want to also have an ErrorExit that checks that the zip code entered by the customer is at least (if not exact) 5 characters, otherwise they could enter just a "3" and the Contains() would match it - e.g.
ErrorExit Zip.Length <> 5 "please enter a correct zip code"
(P.S. Using the shortcut Zip rather than the fully qualified ShippingAddress.ZipPostalCode has been around for some time now. I've just haven't gone back and updated all the older blogs. :)