# shipping of each unique item separately?

Thread began 12/22/2009 5:58 pm by sam308940 | Last modified 1/05/2010 10:58 am by Ray Borduin | 1182 views | 5 replies |

## 12/22/2009 5:58 pm  |  #1 sam308940

### shipping of each unique item separately?

i have shipping setup on a quantity basis.

0-100 = X
100-200 = Y
201-300 = Z

i need to figure out how i can setup shipping so that each UNIQUE item is calculated to ship individually.
Meaning if i have ...100 of itemA and 200 of itemB
i want the shipping to be X+Y (total to ship 100 + total to ship 200)
NOT Z (total to ship 300)

how can i do this?

I have shipping based on QUANTITY, ZONE(based on state), and TYPE (ground, express)

here is the code from 1 shipping definition.

//eCart Rule
function WAEC_pcccart_Ship1_1_150() {
\$totalShipping = 0;
if (true && ((\$this->TotalColumn("Quantity") > 10) && (\$this->TotalColumn("Quantity") < 150) && ((isset(\$_SESSION['ship_stg'])?\$_SESSION['ship_stg']:"") == "1") && ((isset(\$_SESSION['ship_method'])?\$_SESSION['ship_method']:"") == "1"))) {
\$totalShipping += 10;//Result
}
return WA_eCart_FormatNumber(\$totalShipping, \$this->ForceDecimalsC, \$this->DecimalPlacesC);
}
//eCart Rule

THANKS for any help
Sam

## 12/23/2009 2:27 pm  |  #2 Ray BorduinWebAssist

You would probably have to use both Calculation columns and rules in order to accomplish this.

Do you have a grid of shipping to be charged in every case? If I could look at that I might be able to help you with the formulas you would need.

How many zones do you have? Make sure to include the session variable names and what they will contain for the various zones and types and I can probably help you write the necessary formulas.

## 12/23/2009 3:53 pm  |  #3 sam308940

Thanks Ray! (HAVE A GREAT HOLIDAY)

I have the shipping grid in visual format:
card_pop.php?I=SH
there are 3 shipping methods, 6 zones, and 3 qty groups
(not all zones have all shipping methods)

Im attaching the current cart include file - it shows all the shipping options
because of the amount of shipping options, i created 2 of them and from there copied/pasted/handcoded the rest. if you have shorter ways to code (and eliminate shipping rules) please do!

to follow my shipping rules naming logic ill explain 1 of them...
Ship Group #, Method, Max Qty
Ship1_1_150 : this is shipping group 1, method 1(ground), qty <150

on the view cart page: i have a few sessions i create
(im attaching the file)
ship_st - state shipping to (selected on view cart before update or checkout can be submitted)
ship_stg - shipping group (zone). (1-6 in the order show in shipping link)
ship_method - Ground = 1, Priority=2, Express=3 (by default its set to 1)

note - some ZONES dont have some methods.
I have duplicated things to cover any errors occuring.
zones 5/6 do no have 1(ground), method 2 is duplicated as 1
zone 1 only has ground, so i duplicated 1 as method 2/3.
zone 2 doesnt not have 2(priority), so 1 and 2 are the same here.

sam

Attached Files
Desktop.zip

## 12/23/2009 4:54 pm  |  #4 Ray BorduinWebAssist

OK... with this many options I would probably put them into a multi-dimensional array in php and then write a function to return the result. Then I'd add that function to every page that has the cart and refer to it in the calculation.

Unfortunatly I don't have time to do it for you right now and I'm on vacation starting in about an hour until Jan. 4.

Maybe someone else can help you in the meantime, if not I'll try helping when I return.

## 12/23/2009 9:55 pm  |  #5 sam308940

Ray - its no problem about Jan 4. Im gone pretty much till then too!

## 1/05/2010 10:58 am  |  #6 Ray BorduinWebAssist

OK, here is your shipping charges expressed in a php function:

`<?phpfunction getShipCharge(\$cartQuantity)  {  \$shipZone =  isset(\$_SESSION['ship_stg'])?\$_SESSION['ship_stg']:1;  \$shipMethod = isset(\$_SESSION['ship_method'])?\$_SESSION['ship_method']:1;  if (\$cartQuantity < 100)  {  // 1-99 cards purchased    switch (\$shipZone) {      case 1:  // CT, DE, MA, ME, NH, NJ, NY, PA, RI, VT        switch (\$shipMethod) {          case 1:  // UPS Ground            return 10;            break;          }        break;      case 2: //  DC, MD, NC, OH, SC, VA, WV        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 3: // USPS Express            return 30;            break;          }        break;      case 3: // AL, FL, GA, IA, IL, IN, KY, MI, MN, MO,TN, WI        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 2: // USPS Priority             return 18;            break;          case 3: // USPS Express            return 35;            break;          }        break;      case 4: // AK, AR,  AZ, CA, CO, HI, ID, KS, LA, MS, MT, ND, NE, NM, NV, OK, OR, SD, TX, UT, WA, WY        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 2: // USPS Priority             return 18;            break;          case 3: // USPS Express           return 42;            break;          }        break;      case 5: //  United Kingdom & Ireland        switch (\$shipMethod) {          case 2: // USPS Priority             return 35;            break;          case 3: // USPS Express            return 45;            break;          }        break;      case 6: // Canada        switch (\$shipMethod) {          case 2: // USPS Priority             return 28;            break;          case 3: // USPS Express            return 42;            break;          }        break;     }   } else if (\$cartQuantity < 150)  {  // 100 - 149 cards purchased    switch (\$shipZone) {      case 1:  // CT, DE, MA, ME, NH, NJ, NY, PA, RI, VT        switch (\$shipMethod) {          case 1:  // UPS Ground            return 10;            break;          }        break;      case 2: //  DC, MD, NC, OH, SC, VA, WV        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 3: // USPS Express            return 42;            break;          }        break;      case 3: // AL, FL, GA, IA, IL, IN, KY, MI, MN, MO,TN, WI        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 2: // USPS Priority             return 18;            break;          case 3: // USPS Express            return 45;            break;          }        break;      case 4: // AK, AR,  AZ, CA, CO, HI, ID, KS, LA, MS, MT, ND, NE, NM, NV, OK, OR, SD, TX, UT, WA, WY        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 2: // USPS Priority             return 22;            break;          case 3: // USPS Express           return 48;            break;          }        break;      case 5: //  United Kingdom & Ireland        switch (\$shipMethod) {          case 2: // USPS Priority             return 45;            break;          case 3: // USPS Express            return 55;            break;          }        break;      case 6: // Canada        switch (\$shipMethod) {          case 2: // USPS Priority             return 30;            break;          case 3: // USPS Express            return 45;            break;          }        break;     }   } else {  // 150 or more cards purchased    switch (\$shipZone) {      case 1:  // CT, DE, MA, ME, NH, NJ, NY, PA, RI, VT        switch (\$shipMethod) {          case 1:  // UPS Ground            return 12.5;            break;          }        break;      case 2: //  DC, MD, NC, OH, SC, VA, WV        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 3: // USPS Express            return 45;            break;          }        break;      case 3: // AL, FL, GA, IA, IL, IN, KY, MI, MN, MO,TN, WI        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 2: // USPS Priority             return 20;            break;          case 3: // USPS Express            return 52;            break;          }        break;      case 4: // AK, AR,  AZ, CA, CO, HI, ID, KS, LA, MS, MT, ND, NE, NM, NV, OK, OR, SD, TX, UT, WA, WY        switch (\$shipMethod) {          case 1:  // UPS Ground            return 15;            break;          case 2: // USPS Priority             return 25;            break;          case 3: // USPS Express           return 52;            break;          }        break;      case 5: //  United Kingdom & Ireland        switch (\$shipMethod) {          case 2: // USPS Priority             return 55;            break;          case 3: // USPS Express            return 65;            break;          }        break;      case 6: // Canada        switch (\$shipMethod) {          case 2: // USPS Priority             return 35;            break;          case 3: // USPS Express            return 55;            break;          }        break;     }   }   return 0;}?>`

If you either add that code to an include file, or add the code itself, and put in on every page that has an ecart object on it.

Then go to the cart object definition Calculations tab and add a calculation that uses this function like:

RowShipping = getShipCharge([Quantity]);

Then you can create a single shipping rule to charge the total column value of the RowShipping calculation created.

## 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 --