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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Custom Shipping from database

Thread began 3/25/2011 2:41 pm by bjgarner241692 | Last modified 3/25/2011 4:21 pm by bjgarner241692 | 906 views | 6 replies |

bjgarner241692

Custom Shipping from database

I've setup country and state / province in my db with a shipping premium so that they each have a base rate for orders to that region.

I started with a simple Flat Rate amount to get it working initially. That's all fine.

Now I want to substitute my flat rate of .02 with the value from the db.

php:
//eCart Rule

function WAEC_eCart1_Country()  {
  $totalShipping = 0;
  if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['eCartCheckoutForm_country'])))) {
    $totalShipping +=  '".$row_shipcountry['ShipPremium']."';//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
{



This is in eCart1.php
Recordset shipcountry is on confirm.php. Session values and Recordset works fine.

My problem is syntax.
I get:
Parse error: syntax error, unexpected T_STRING in C:\Inetpub\vhosts\drjacknewman.com\httpdocs\2011\WA_eCart\eCart1_PHP.php on line 99

Line 99 is of course the line that includes:
'".$row_shipcountry['ShipPremium']."'

i have also tried <?php echo $row_shipcountry['ShipPremium']; ?> with a similar type of error.

Please help if you can.
Thanks,

Sign in to reply to this post

Jason ByrnesWebAssist

change:

php:
$totalShipping +=  '".$row_shipcountry['ShipPremium']."';//Result



to:

php:
$totalShipping += "".$row_shipcountry['ShipPremium']."";//Result
Sign in to reply to this post

bjgarner241692

Thank you.

That eliminated my error, but the amount is not being added to my shipping value so I still have some work to do.

I've placed the premiums on the page so that I can see that they are correct so that's not it.

Perhaps I should be doing this with the calculations tab.

Sign in to reply to this post

Jason ByrnesWebAssist

try storing the ShipPremium amount from the recordset into a session variable and using the session variable value in the charge rule instead of the recordset value.

Sign in to reply to this post

bjgarner241692

OK,
So I setup the Session Value on the confirm page, trigger is if rs is not empty.

then I changed the shipping calc to this on eCart1.php

php:
//eCart Rule

function WAEC_eCart1_Country()  {
  $totalShipping = 0;
  if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['eCartCheckoutForm_country'])))) {
$totalShipping += "".$SESSION['shipcountry']."";//Result  
}
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



No errors. Session Values are correct, but still no shipping amount.

Seems like it is still a Syntax issue, in getting that value to register as a number.

Sign in to reply to this post

bjgarner241692

Since I now have the number I need in a Session Value I simplified the shipping rule to:

php:
//eCart Rule

function WAEC_eCart1_Country()  {
  $totalShipping = 0;
  if (true && ((sizeof($this->Items) > 0) && ((isset($_SESSION['shipcountry'])?$_SESSION['shipcountry']:"") > "0"))) {
    $totalShipping += "".$SESSION['shipcountry']."";//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



but it still ignores it.

Just to check, I substituted

php:
"".$SESSION['shipcountry'].""



with 10, and the rule works fine, adding $10.00.

Has to be syntax.

Sign in to reply to this post

bjgarner241692

This worked.

php:
//eCart Rule

function WAEC_eCart1_Country()  {
  $totalShipping = 0;
  if (true && ((sizeof($this->Items) > 0) && ((isset($_SESSION['shipcountry'])?$_SESSION['shipcountry']:"") > "0"))) {
    $totalShipping += $_SESSION['shipcountry'];//Result
  }
  return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



Thank you for your assistance. Hope this helps someone else.

Key was getting a Session Variable with the number I needed.

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