calculations

SurfShop™ allows for amounts to be added to, or deducted from, the customer's order based on an endless combination of variables. Examples are Tax, Discounts, Shipping and Handling charges. You should be able to generate virtually any amount using the SurfShop™ calculation system.

Calculations can be added to the total before tax or after the tax is calculated. They can also be calculated as a line item that is not added to the total for areas which may calculate tax as inclusive. Calculations can be compounded by taking the percentage of the result of a previous calculation.

**Calc Name**

This is the name you give the calculation as it will appear in the totals column of the order. Examples might be “Sales Tax,” “UPS Ground,” “FedEx Overnight,” “Discount” or “Handling”

**Calc Type**

This is the primary method of generating the result. All calculations fall into one of the following “calculation types”:

- straight - one fixed value, no tests involved
- field - result is determined by the value of a specific field: state, zip, country, etc.
- quantity - result is determined by the the number of items in the customer's order.
- subtotal - result is determined by the the subtotal of the customer's order.
- weight - result is determined by the total weight of the customer's order.
- volume - result is determined by the total volume of the customer's order.
- lookup - result is determined using a separate “lookup” table.

**Tests, Values**

This field contains the values that generate the result of the calculation. It may be a single value, or a matrix of values.

**Cross Type**

This is the secondary method of generating the result in a two-dimensional calculation. The Cross Type field can be one of any of the values listed in the “Calc Type” field.

**Cross Tests**

This field contains the values that generate the result column in a two-dimensional calculation.

**By Field**

This contains the name of the data field that is used to genarate the result in a “Field” type calculation.

**% of**

In a percentage-based calculation, this field contains the order amount used to generate the result.

**Add to Subtotal**

This field decides whether the result of the calculation is added before tax, as tax, or after tax. Non-Shipping Calculations can also be designated as “inclusive,” which means that the total returned is not automatically added to the “chargetotal” amount of the order. This is used in jurisdictions where the tax is not added to the total, but is instead included in the sales price of the item (ex: Australia).

**Lookup**

In the case of a “Lookup” type calculation, this field contains the name of the calculation used to generate the result.

**This is a Shipping Type**

This can either be “checked” or “not checked” and tells SurfShop™ whether or not to treat the calculation as a shipping method.

**Show in totals column**

This can either be “checked” or “not checked” and tells SurfShop™ whether or not to show the calculation as a line item in the totals column of the order.

Percentage calculations can be based on one of six order amounts:

Order Subtotal | Total of the order, before any calculations are added. |

Volume Subtotal | Total of volume, before any calculations are added. |

Taxable Subtotal | Total of taxable items, before any calculations are added. |

Pre-Tax Order Total | Total of the order + subtotal calculations. |

Pre-Tax Taxable Total | Total of the taxable items + subtotal calculations. |

After-Tax Total | Total of the order + subtotal calculations + “pre-tax” calculations |

After-Tax Taxable Total | Total of the taxable items + subtotal calculations + “pre-tax” calculations |

A few examples:

- A discount is usually based on the “Order Subtotal”
- Sales Tax is usually based on the “Pre-Tax Taxable Total”
- A finance charge is usually based on the “After-Tax Total”

Therefore:

- A calculation based on the “Pre-Tax Total” would include all calculations based on the “Taxable Subtotal” or the “Order Subtotal” but would not include “Inclusive” or “Lookup” Calculations.
- A calculation based on the “After-Tax Total” would include all calculations based on the “Pre-Tax Taxable Total” or the “Pre-Tax Total” but would not include “Inclusive” or “Lookup” Calculations.

The simplest calculation is a straight calculation. This calculation returns either a constant value or a percentage of one of the order amounts listed above. Discounts and Handling charges are examples of Straight Calculations.

(Fields that don't apply are marked “–”)

Calc Name: Handling Calc Type: _straight Tests, Values: 5.00 Cross Type: -- Cross Tests: -- By Field: -- % of: Not a Percentage Add to Subtotal: Before Tax Lookup: -- This is a Shipping Type: (not checked) Show in totals column: (checked)

This calculation would always add a $5.00 handling charge to the order with the line item label of “Handling” in the totals column.

(Fields that don't apply are marked “–”)

Calc Name: Discount Calc Type: _straight Tests, Values: -5% Cross Type: -- Cross Tests: -- By Field: -- % of: Order Subtotal Add to Subtotal: Before Tax Lookup: -- This is a Shipping Type: (not checked) Show in totals column: (checked)

This calculation would always subtract 5% of the order subtotal from the order with the line item label of “Discount” in the totals column.

The next kind of calulation looks at a value in the customer's order (chosen in the “Calc Type” field) and generates the result from a list of values in the “Tests, Values” field.

SurfShop™ compares the customer's order to the list and returns the corresponding value. If the calculation is numeric, it returns the first value greater-than or equal to the test value. If the calculation is a “field” type, it returns the first value that matches the test value. If a plus sign (“+”) is encountered before a match, Surf Shop returns that row.

- For a field type calculation, SurfShop™ compares the value of the customers order corresponding to the “By Field” menu, and returns first row that matches.
- For a quantity type calculation, SurfShop™ returns the first row that matches the total quantity of items in the customer's order.
- For a subtotal type calculation, SurfShop™ returns the first row that matches the subtotal of the customer's order.
- For a weight type calculation, SurfShop™ returns the first row that matches the total weight of the customer's order.
- For a volume type calculation, SurfShop™ returns the first row that matches the total volume of the customer's order.
- For a lookup type calculation, SurfShop™ returns the first row that matches the result of the lookup calculation (see Lookup Tables, below).

If you wish to set up Sales Tax in your state (for this example, we'll use Tennessee), start by creating a calculation named “Sales Tax.” Enter “field” in the “Calc Type” menu and “Ecom_BillTo_Postal_StateProv” in the “by Field” menu. In Tennessee, we have 9.25% sales tax, so you would enter “TN,9.25%” in the “Test,Value” input area. Finally, you would probably select “Pre-Tax Total” in the “% Of” field, since this is a “percentage” calculation. Since this will be applied automatically to all orders, the “This is a Shipping Type” checkbox SHOULD NOT be checked, but “Show in Totals Column” SHOULD be checked.

Calc Name: Sales Tax Calc Type: _field Tests, Values: TN, 9.25% Cross Type: -- Cross Tests: -- By Field: Ecom_ShipTo_Postal_StateProv % of: Pre-Tax Total Add to Subtotal: As Tax Lookup: -- This is a Shipping Type: (not checked) Show in totals column: (checked)

In this example, SurfShop™ checks the value of the customer's “Ship To” state and compares it to the “Tests, Values” field. If the customer is shipping to “TN,” then it calculates 9.25% of the “Pre-Tax Total” of the order and returns it as the result.

If the customer is shipping to any destination other than “TN,” the calculation result will be zero.

You can base a shipping calculation on the total of the customers order by selecting the _subtotal type.

In this example, first notice that “This is a Shipping Type” is checked. This tells the program to include the calculation in the list of shipping methods. “Show in totals column” is not checked, telling the program not to automatically include it as a line item in the totals column.

In the “Test, Value” area, enter the order amounts and their associated shipping rates. (Fields that don't apply are marked “–”)

Calc Name: Ground Freight Calc Type: _subtotal Tests, Values: 15,2.50 30,5.00 50,7.50 75,10.00 100,12.50 +,15.00 Cross Type: -- Cross Tests: -- By Field: -- % of: Not a Percentage Add to Subtotal: After Tax Lookup: -- This is a Shipping Type: (checked) Show in totals column: (not checked)

In this example, SurfShop™ first looks at the subtotal of the customers order.

*Note: This will always be the Order Subtotal amount, before any calculations are added.*

It then goes through the rows in the “Tests, Values” field until it finds a value greater than or equal to the Subtotal.

Lets assume that the customer has ordered $55.00 worth of merchandise. The first row greater than or equal to 55 is “75”, so SurfShop™ would return $10.00 as the result.

Calculations can be based on two separate parameters. An example of a two-dimensional calculation would be a shipping calculation generated by the customer's destination country and the total weight of the order.

To set up this kind of calculation, you use the “Cross Type” and “Cross Tests” fields. Cross Types can only be of the “quantity,” “subtotal,” “weight,” “volume” or “lookup” variety. If a “field” is used to generate the result, it must be the primary “Calc Type.”

In this example, first notice that “This is a Shipping Type” is checked. This tells the program to include the calculation in the list of shipping methods. “Show in totals column” is not checked, telling the program not to automatically include it as a line item in the totals column.

Calc Name: Ground Freight Calc Type: _field Tests, Values: US, 2.50, 3.50, 4.50, 5.50, 6.50, 7.50, 10.00 CA, 3.50, 4.75, 6.00, 7.25, 8.50, 9.75, 11.00 +, --, --, --, --, --, --, -- Cross Type: _weight Cross Tests: 5, 7, 9, 11, 15, 20, + By Field: Ecom_ShipTo_Postal_CountryCode % of: Not a Percentage Add to Subtotal: After Tax Lookup: -- This is a Shipping Type: (checked) Show in totals column: (not checked)

In this example lets assume the customer's order totals 10 lbs. (assuming we are measuring in pounds) and the customer's destination country is Canada.

SurfShop™ first looks at the customer's “Ship To” country, indicated by the “By Field” menu selection. It then compares this value to the “Tests,Values” field to generate a row of possible shipping amounts. If the country is not one of the choices, SurfShop selects the “+” row. In this example, Surf Shop would select the second row, corresponding to “CA,” the customer's destination Country.

The program then looks at the total weight of the customer's order, indicated by the “Cross Type” menu. It compares this value to the “Cross Tests” field to determine which of the shipping amounts to use.

SurfShop™ would then take the fourth value, since the first value in the “Cross Tests” field that is greater than or equal to the total weight is “11.” The fourth value in the “CA” row is “7.25,” so the program would return $7.25 as the shipping charge.

If you wish to set up shipping by State and then by weight, start by creating a calculation named “Shipping,” or whatever you wish to call it: “US Mail,” “UPS,” etc. Enter “Ecom_BillTo_Postal_StateProv” in the “by Field” menu and “_weight” in the “Cross Type” field. Then enter the weight tests in the “cross test” field (with “+” being the catch-all). In this example, this shipping type would only be available to the 50 US states.

Calc Name: Ground Freight Calc Type: _field Tests, Values: AK,17,17.50,18,18.50,19 AL,6,6.50,7,7.50,8 AR,6,6.50,7,7.50,8 AZ,7,7.50,8,8.50,10 CA,7,7.50,8,8.50,10 CO,7,7.50,8,8.50,10 CT,6.50,7,7.50,8,8.50 . . . etc. . . . VT,6.50,7,7.50,8,8.50 WA,7,7.50,8,8.50,10 WI,7,7.50,8,8.50,10 WV,6,6.50,7,7.50,8 WY,7,7.50,8,8.50,10 (+),--,--,--,--,-- Cross Type: _weight Cross Tests: 5,10,15,20,+ By Field: Ecom_ShipTo_Postal_CountryCode % of: Not a Percentage Add to Subtotal: After Tax Lookup: -- This is a Shipping Type: (checked) Show in totals column: (not checked)

Any value of “–” (double dash) is treated “Not Applicable” and will be not be calculated by Surf Shop. If the calculation returns zero, it will not be shown in the “Shipping Method” dropdown menu.

In this example, a customer from Connecticut whose order has a total weight of 16 would be charged $8.00.

*You must convert your wieght and volume values into a single unit of measure.*The weight and volume attributes of an item can be any unit of measure, so long as it always the same unit of measure for all items. One item cannot be measured in ounces and another in kilos, for example.

If you wish to multiply the number of items in a customer's order (or the subtotal of the order) by a fixed amount, you can use a multiplier instead of a set value. If you include an asterisk (*) with the value in the “Tests, Values” field, Surf Shop will multiply the result of the “Tests, Values” by the result of the “Cross Type.” For example, to multiply the total quantity of the order by 2.50, create the following calculation:

Calc Name: Ground Freight Calc Type: _quantity Tests, Values: +,2.50<nowiki>*</nowiki> Cross Type: _quantity Cross Tests: + By Field: -- % of: Not a Percentage Add to Subtotal: After Tax Lookup: -- This is a Shipping Type: (checked) Show in totals column: (not checked)

In this example, an order with a total of 15 items would be charged $2.50 x 15, or $45.00 shipping.

*The 2 dimensional method must be used in order to utilize this feature.*

This type of calculation uses the result of a second calculation to generate the test value for the first.

A Lookup Table is basically a calculation whose result drives the result of another calculation.

To designate a calculation as a “lookup” table, choose “Lookup Table - Do not add” in the “Add to Subtotal” menu. The calculation then appears in the “Lookup” menu once it is saved.

Lookup Tables are not added to the Totals column, nor do they appear in the Shipping Methods menu at checkout. They exist only as a means to generate a value for a seperate calculation.

A common use of Lookup Tables is for Shipping Zones. Many carriers group destinations into zones based on Zip Code. It would be a massive undertaking to include every weight value for every zip code in the US. Instead, we generate the Zone using a Lookup Table, then use the result to generate the shipping amount based on weight or volume.

If you wish to use UPS or FedEx shipping tables, which base the rate on **shipping zones** as they relate to your place of business, you can use the **lookup** calcuation type to find the appropriate Zone, then apply it to the Shipping calculation to generate the result.

To use a separate Lookup Table, select “_lookup” in the “Calc Type” or “Cross Type” fields. Usually the “Cross Type” is used. You must then select a calculation to use for the Lookup in the “Lookup” menu. Calculations that have been saved as “Lookup Tables” will appear in this menu.

In this example, the first calculation is called “Ground Freight,” and the second (Lookup) calculation is called “Freight Zones.”

First, lets create the “Freight Zones” Calculation:

Calc Name: Freight Zones Calc Type: _field Tests, Values: 001,-- 002,-- 003,-- 004,5 005,5 010,5 011,5 . . . etc... . . . 990,7 991,7 992,7 993,7 994,7 +,-- Cross Type: -- Cross Tests: -- By Field: Ecom_ShipTo_Postal_PostalCode % of: Not a Percentage Add to Subtotal: Lookup Table - Do not add Lookup: -- This is a Shipping Type: (not checked) Show in totals column: (not checked)

**Comments:**

- Neither “This is a Shipping Type” nor “Show in totals column” is checked. This makes sure that the result of this calculation is only used as a Lookup table.
- In the “Add to Subtotal” field, “Lookup Table - Do not add” is selected. This tells SurfShop™ to include this calculation in the “Lookup” menu as a Lookup Table.
- This is a “field” calculation, and generates its result from the value of the “Ecom_ShipTo_Postal_PostalCode” field of the customer's order.
- The “Tests, Values” field only contains the first three digits of the zip code.
because to include all the zip codes would create an unnecessarily large table. UPS and FedEx both handle shipping zones this way. SurfShop™ will match the zip code based on the first three digits.**This is important to note**

Now, lets create the actual shipping calculation:

Calc Name: Ground Freight Calc Type: _weight Tests, Values: 1,8.00,8.30,8.50,8.90,9.60,10.10,10.40,16.60,22.80,10.60,-- 2,8.30,8.50,8.80,9.60,11.20,12.00,12.20,18.40,24.10,10.90,-- 3,8.50,8.80,9.30,10.80,12.80,13.30,13.80,22.50,25.10,12.70,-- 4,8.80,9.00,10.30,12.40,14.10,15.20,15.70,23.30,26.20,14.80,-- 5,9.00,9.30,11.30,13.70,16.00,16.80,17.80,24.30,27.20,16.30,-- . . . etc... . . . 147,95.55,111.72,141.12,186.69,254.31,273.42,283.71,289.59,320.46,195.51,-- 148,96.20,112.48,142.08,187.96,256.04,275.28,285.64,291.56,322.64,196.84,-- 149,96.85,113.24,143.04,189.23,257.77,277.14,287.57,293.53,324.82,198.17,-- 150,97.50,114.00,144.00,190.50,259.50,279.00,289.50,295.50,327.00,199.50,-- +,--,--,--,--,--,--,--,--,--,--,-- Cross Type: _lookup Cross Tests: 2,3,4,5,6,7,8,10,12,16,+ By Field: -- % of: Not a Percentage Add to Subtotal: After Tax Lookup: Freight Zones This is a Shipping Type: (checked) Show in totals column: (not checked)

**Comments:**

- The “Calc Type” field contains “weight,” meaning this calculation will return its result based on the total weight of the customers's order.
- The “Cross Type” field is “lookup,” which tells SurfShop™ to get the appropriate value from the result of a Lookup Table instead of from one of the standard order values (subtotal, weight, volume, other, etc.).
- The “Lookup” field references the “Freight Zone” calculation we just created.
- The “Cross Tests” field contains the possible zones returned by the “Freight Zones” calculation.
- “This is a Shipping Type” is checked. This tells the program to include the calculation in the list of shipping methods.
- “Show in totals column” is not checked, telling the program not to automatically include it as a line item in the totals column.

For this example, lets assume the customer's Zip code is “99223” and the total weight of the order is 4.25 lbs.

First, SurfShop™ looks at the “Cross Type” field. Since it is set to “lookup” the result, it then checks the appropriate table.

Second, since the “Lookup” field contains “Freight Zones,” Surf Shop runs the second calculation. It tells it to use the customer's Zip code, and compare it to the list of possible zip codes. The matching row starts with “992” so it returns “7” as the Zone.

Third, it looks at the total weight of the order, because this is a “weight” calculation. The program searches the possible weight values and stops at 5, since this is the first row that is greater than or equal to the total weight of the order. Since the “Cross Test” value is “7” (from the Lookup Table calculation), it returns the sixth value, or “16.80.”

SurfShop™ then returns $16.80 as the shipping amount for this order.

See Shipping Calculations for more information about shipping calculations.

You can make one calculation generate its result based on the percentage of the result of another. This is what we call a **Compound Calculation**.

If you want to take a percentage of the total order after tax is added, set the “% of” field to “After-Tax Total” and set the “Add to Subtotal” field to “After Tax.”

(Fields that don't apply are marked “–”)

Calc Name: Finance Charge Calc Type: _straight Tests, Values: 5% Cross Type: -- Cross Tests: -- By Field: -- % of: After-Tax Total Add to Subtotal: After Tax Lookup: -- This is a Shipping Type: (not checked) Show in totals column: (checked)

This calculation will generate a result based on the total of the order after all the other calculations have been added. For example, if the total order after Tax is $25.00, SurfShop™ will return 5% of 25, or $1.25 for the calculation.

*Note: For calculations to be included in the “After Tax” calculation, they must be set to “Pre-Tax” or “As Tax” in the “Add to Subtotal” menu.**Likewise, for other calculations to be included in the “As Tax” calculation, they must be set to “Pre-Tax” in the “Add to Subtotal” menu.*

You can make SurfShop add a flat rate to the calculation result by inserting a value in the first line of the “Tests, Values” field, starting with an equals sign (“=”).

(Fields that don't apply are marked “–”)

Calc Name: Shipping/Handling Calc Type: _weight Tests, Values:

====== 2.00

+,0.25* Cross Type: _weight Cross Tests: + By Field: -- % of: Not a Percentage Add to Subtotal: After Tax Lookup: -- This is a Shipping Type: (checked) Show in totals column: (not checked)

This calculation will generate a result based on the total weight of the order multiplied by $0.25 plus a flat rate of $2.00. For example, if the total weight is 15, SurfShop™ will return $0.25 x 15 + $2.00, or $5.75 for the calculation.

The calculation must be a 2- or 3-dimensional calculation to use this feature. I will not work with a “straight” calculation.

calculations.txt · Last modified: 2018/07/03 04:55 (external edit)