# Formula for shipping sizes

Thread began 5/13/2011 10:27 am by James L | Last modified 5/16/2011 7:19 am by Jason Byrnes | 1093 views | 3 replies |

## 5/13/2011 10:27 am  |  #1 James L

### Formula for shipping sizes

My client has a product that is available only in quantities of 1, 2, or 3. A single item ships in a box 8"x5"x5". But 2 or 3 items will ship in a box 14x8x5. In the checkout wizard for UPS shipping one must list the length, width, & height. I see that the lightning bolt lets me connect to a field, so I added three fields to "Items" -- ItemLength, ItemWidth, & ItemHeight. Is there a way to dynamically populate these fields with a size based on the Quantity?

## 5/13/2011 1:33 pm  |  #2 Jason ByrnesWebAssist

so only the height and width will change.

Create 2 calculations in the eCart object:

height:
abs([Quantity] == 1)?[ItemHeight]=8:[ItemHeight]=14

width:
abs([Quantity] == 1)?[ItemWidth]=5:[ItemWidth]=8

hard set the length at 5.

## 5/13/2011 7:47 pm  |  #3 James L

this doesn't seem logical to me. There's no accounting for the 1 item box and the 2-3 items box. Should it not be something like:
abs([Quantity] == 3)?[ItemHeight]=8:[ItemWidth]=14
abs([Quantity] == 2)?[ItemHeight]=8:[ItemWidth]=14
abs([Quantity] == 1)?[ItemHeight]=8:[ItemWidth]=5

## 5/16/2011 7:19 am  |  #4 Jason ByrnesWebAssist

the calculation is using a ternary expression.

a ternary expression is a shortened if statement using the following format:

expresion?true statement:False statement

in other words, this statement:
height:
abs([Quantity] == 1)?[ItemHeight]=8:[ItemHeight]=14

means:
Quantity == 1?

yes: Set the Item Height to 8

No: Set the item height to 14

the height be set to 14 if the quantity is anything other than 1. Set the quantity to 2 or 3, the height will be set to 14

## Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

## Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

## Everything else!

Close Window

Account or customer service questions?

Need technical support?

Content

Layout

Ease of use

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Window

## We were unable to retrieve the attached file

Close Window

### Attach and remove files

• Text Formatting
• Insert Element
• Block Formatting
• Cancel
Close Window

Close Window

#### This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --