# Algorithm Based Examples

## 1. SURCHARGE_ORDER Algorithm

To surcharge an existing rate by a fixed amount the SURCHARGE_ORDER algorithm will be used.

This example CSV will surcharge any methods named “Ground” by 5 when they are assigned the SURCHARGE shipping group or discount by 5 when they are assigned the DISCOUNT shipping group.

## 2. OVERRIDE Algorithm

You can use the OVERRIDE algorithm to override all other rates for all other products in the cart.  For example let’s say you have a set of products which you want to offer FREE shipping on when the cart value is > \$200.   In addition to this you sell plants, and for these you want to add a \$5 surcharge per order when these are in cart. You want to offer FREE shipping on the whole cart when the FREE products are in the cart, otherwise apply the surcharge with normal rates.

To do this you would set the following criteria on row 1:

1. Shipping Group = FREE_OVERRIDE
2. Price From = 200
3. Delivery Type = Ground
4. Algorithm = OVERRIDE

On row 2 setup the plants:

1. Shipping Group = PLANTS
2. Delivery Type = Ground
3. Algorithm = SURCHARGE_ORDER

override-algorithm CSV

## 3. SURCHARGE_PECENTAGE_CART Algorithm

In this example there is a \$45 product in the cart. Flat Rate has been configured to with a rate of \$100 per order.
When the “Shipping Price” field has been specified the percentage of the shipping price will be added:
This will result in a rate of \$100 + (10% of \$100) = \$110When the “percentage” field has been specified the percentage of the products in the cart will be added:

This will result in a rate of \$100 + (10% of \$45) = \$104.50.​​

Assume you have two conditions and want to add this to the algorithm

• You want to charge a flat rate on certain products per order
• An additional per item price on these products

So for example 1*item = \$10, additional item price \$3.95. 2*items would be \$13.95 and 3*items would be \$17.90.

The above conditions can be achieved using the excel file below.

## 5. ORDER Algorithm

With this example CSV the items assigned to the FLAT group will receive a flat rate of 10 for the “Ground” method. Items assigned to the FREE group will receive a rate of 0 for the “Ground” method.

Note that the ORDER algorithm sets the rate for the group. Thus, if there is a FLAT and a FREE product in the cart together the shipping rate for “Ground” will be 10 (10 for FLAT, 0 for FREE).

See the shipping group examples page for more examples for the ORDER algorithm.

## 6. ORDER_RES and ORDER_COM Algorithms

Let’s say you want to charge different table-based rates for shipments for a specific shipping method based on their address type. You can do this by using the ORDER_RES and/or ORDER_COM algorithms.

The price you specify becomes the price used for the products that match the criteria specified, just as it does with the ORDER algorithm.
Please note that these algorithms are only for use with WebShopApps extensions that have address type functionality, such as our freight extensions or Residential Commercial Selector extensions.

## 7. ERROR Algorithm

The error= algorithm allows for custom error messages to show when no rates are available from a specific carrier within your store.

In the CSV file below it shows that when shipping to the states of Alaska and Hawaii that the shipping method of UPS Ground cannot be shown.

So when shipping to these states the error message that is entered into the error= algorithm and column will be displayed.

This screenshot shows the rates when shipping to the state of California (CA)

The screenshot below shows the error message when shipping to the state of Hawaii (HI)

Please ensure you have the error messaging switched on for the Shipping Override extension as shown below:

## 8. ORDER_FREE Algorithm

This algorithm applies when a order is granted free shipping through a Magento promotional rule. You could use this to set multiple methods as free shipping (Magento only lets you choose one free method) or hide other shipping methods when free shipping is applied.

In this example, we’re going to hide two shipping methods called Overnight and 2 Day and ensure the method Standard is free. You’ll also notice that we’re using pattern matching in this example which is discussed here: Pattern Matching (See Advanced)

ORDER_FREE Shipping Override