close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Inherited (?) shipping rules

Thread began 7/14/2010 1:35 pm by whit368229 | Last modified 7/19/2010 6:37 pm by Eric Mittman | 962 views | 5 replies |

whit368229

Inherited (?) shipping rules

Using CS3/PS2/eCart5/PHP: I have 4 categories, all with flat rate shipping.

CategoryID 1 : rules works fine
CategoryID 2 : this is the problem child!
CategoryID 3 : not live
CategoryID 4 : rules works fine

CategoryID 2 is parts. PartsShipping should be flat rate $9.50/box. Each box = 1 to 4 parts/box. Carrying on from: showthread.php?t=507, I created a column (PartsShipping) and added a calculation PartsShipping=abs([CategoryID] == 2) * [Quantity]. That didn't work, so I went to what you see below. PartsShipping is now $9.50 no matter what the quantity. For testing, I changed the amount to $5.00, but the grand total still calculated $9.50. So I removed (deleted) the rule and the PartsShipping column all together, and parts still showed up in the cart at $9.50. I can't see where the $9.50 is coming from?
Calculations column:

php:
//start node

  function ResetCalculations($itmObj)     {
   $itmObj->TotalWeight = $itmObj->Weight * $itmObj->Quantity;//w
   $itmObj->TotalPrice = $itmObj->Price * $itmObj->Quantity;//c
   $itmObj->FullDetails = $itmObj->Quantity . ' ' . $itmObj->Name . ' (' . $itmObj->ID . ')';//t
   $itmObj->PaperShipping = abs($itmObj->CategoryID == 4) * $itmObj->Quantity;//n
   $itmObj->TargetShipping = abs($itmObj->CategoryID == 1) * $itmObj->Quantity;//n
   $itmObj->PartsShipping = abs($itmObj->CategoryID == 2) * $itmObj->Quantity;//n
    return $itmObj;
  }
//end node



Shipping column:

php:
//Shipping

  $this->Shipping[] = new WA_eCart_Rule(urldecode("SportsmanShipping"), true, "WAEC_WA_Store_Cart_SportsmanShipping");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("ProShipping"), true, "WAEC_WA_Store_Cart_ProShipping");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("QualifierShipping"), true, "WAEC_WA_Store_Cart_QualifierShipping");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("TacticalShipping"), true, "WAEC_WA_Store_Cart_FlatRate_Tactical");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("UPS%20Shipping"), false, "WAEC_WA_Store_Cart_UPSShipping");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("Paper30"), true, "WAEC_WA_Store_Cart_Paper30");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("Paper20"), true, "WAEC_WA_Store_Cart_Paper20");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("Paper10"), true, "WAEC_WA_Store_Cart_Paper2");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("FreePaper"), true, "WAEC_WA_Store_Cart_FreePaper");
  $this->Shipping[] = new WA_eCart_Rule(urldecode("PartsShipping"), true, "WAEC_WA_Store_Cart_PartsShipping");
}
//end node



The rules:

php:
//eCart Rule

function WAEC_WA_Store_Cart_SportsmanShipping()  {
  $totalShipping = 0;
  if (true && (($this->ConditionalTotal("Quantity", "ID", "1") > 0))) {
    $totalShipping += ($this->ConditionalTotal("Quantity", "ID", "1") * 17.50);//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_ProShipping()  {
  $totalShipping = 0;
  if (true && (($this->ConditionalTotal("Quantity", "ID", "2") > 0))) {
    $totalShipping += ($this->ConditionalTotal("Quantity", "ID", "2") * 21.50);//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_QualifierShipping()  {
  $totalShipping = 0;
  if (true && (($this->ConditionalTotal("Quantity", "ID", "3") > 0))) {
    $totalShipping += ($this->ConditionalTotal("Quantity", "ID", "3") * 25.50);//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_FlatRate_Tactical()  {
  $totalShipping = 0;
  if (true && (($this->ConditionalTotal("Quantity", "ID", "4") > 0))) {
    $totalShipping += ($this->ConditionalTotal("Quantity", "ID", "4") * 29.50);//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_UPSShipping()  {
  $totalShipping = 0;
  if (false && (("UPS"=="UPS")&&(isset($_SESSION["WA_Store_Cart_UPS_Quote"]))&&(floatval($_SESSION["WA_Store_Cart_UPS_Quote"]) != 0))) {
    $totalShipping += floatval($_SESSION["WA_Store_Cart_UPS_Quote"]) + 0;//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_Paper30()  {
  $totalShipping = 0;
  if (true && (($this->ConditionalTotal("Quantity", "CategoryID", "4") > 20) && ($this->ConditionalTotal("Quantity", "CategoryID", "4") <= 30) && ($this->ConditionalTotal("Quantity", "CategoryID", "1") == 0))) {
    $totalShipping += 28.50;//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_Paper20()  {
  $totalShipping = 0;
  if (true && (($this->ConditionalTotal("Quantity", "CategoryID", "4") > 10) && ($this->ConditionalTotal("Quantity", "CategoryID", "4") <= 20) && ($this->ConditionalTotal("Quantity", "CategoryID", "1") == 0))) {
    $totalShipping += 19.00;//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_Paper2()  {
  $totalShipping = 0;
  if (true && (($this->ConditionalTotal("Quantity", "CategoryID", "4") <= 10) && ($this->ConditionalTotal("Quantity", "CategoryID", "1") == 0))) {
    $totalShipping += 9.50;//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_FreePaper()  {
  $totalShipping = 0;
  if (true && (($this->InCart("TargetShipping") == true) && ($this->TotalColumn("PaperShipping") <= 10))) {
    $totalShipping += ($this->TotalColumn("PaperShipping") * 0);//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_PartsShipping()  {
  $totalShipping = 0;
  if (true && (($this->InCart("PartsShipping") == true) && ($this->TotalColumn("PartsShipping") > 0) && ($this->TotalColumn("PartsShipping") <= 4))) {
    $totalShipping += 5.00;//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



Thanks...

Sign in to reply to this post

Eric Mittman

It looks like based on your calculation here that the PartsShipping column would only ever have 0 or the quantity of that particular item that matched the category.

Where are you seeing it as $9.50? Could you post back with a copy of your eCart folder in a zip archive so that we can take a look at it directly and do some testing? I think this would be the best way to try and resolve this.

Sign in to reply to this post

whit368229

Thanks for the reply. Since posting yesterday, I've been banging away. These calculations now work GREAT (thanks!!):
PartsShipping = abs([CategoryID] == 4) * [Quantity]
PaperShipping = abs([CategoryID] == 10) * [Quantity]
But I'm stuck on one last rule. FreePaper (below and attached in my WA_eCart). This rule has now replaced the former rule which was giving problems.

php:
//eCart Rule

function WAEC_WA_Store_Cart_Paper2()  {
  $totalShipping = 0;
  if (true && (($this->InCart("TargetShipping") != true) && ($this->ConditionalTotal("Quantity", "CategoryID", "4") > 0))) {
    $totalShipping += (ceil($this->TotalColumn("PaperShipping")/10) * 9.50);//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_FreePaper()  {
  $totalShipping = 0;
  if (true && (($this->InCart("TargetShipping") == true) && ($this->ConditionalTotal("Quantity", "CategoryID", "4") > 0))) {
    $totalShipping += (ceil($this->TotalColumn("PaperShipping")/10) * 0);//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



Thanks again! Once I have this worked out, it'll be smooth sailing!
--
whit

Attached Files
WA_eCart.zip
Sign in to reply to this post

Eric Mittman

These two rules pretty close, does the first one, Paper2 work for you? Looking at the second one it seems that calculation you are performing is multiplying by 0, this will always yield 0 as the result.

If you want to leave the result of the calculation as it is you would multiply this by 1 instead.

Sign in to reply to this post

whit368229

Yes, Paper2 works fine. The only difference between the 2 rules are:
if (true && (($this->InCart("TargetShipping") == true)
and
if (true && (($this->InCart("TargetShipping") != true) .

If TargetShipping (which are also CategoryID 1 items) are NOT in the cart, shipping for 1 to 10 paper items is $9.50. If TargetShipping (which are also CategoryID 1 items) IS in the cart, shipping total for 1 to 10 paper items is free.

So, if a person ordered a TargetShipping (CategoryID==1) item which had a flat rate shipping charge of $17.50 AND 1 to 10 PaperShipping (CategoryID==4) items, the total shipping charge would be the $17.50.

As it is now, the total shipping calculates $17.50 + $9.50 = $27.00 total instead of $17.50, which tells me that this: if (true && (($this->InCart("TargetShipping") == true)
is being ignored.

Sign in to reply to this post

Eric Mittman

The last rules that you posted has one of them setting the shipping to 0. Have you updated this in the new rule? Shipping rules cannot be used to give a discounted shipping or a 0 shipping charge. You can only ever charge for shipping, not set it to 0. So if you would like for only 17.50 to be charged then the rule that charges 9.50 would need to account for the other conditions and not charge when they are present.

If you continue to have any problems with this please post back with the updated fies with the charge rules in them and an example of what the shipping charges should be for a given test item.

Sign in to reply to this post

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

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 Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

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

Uploading file...