close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

shipping calculations are not correctly calculated

Thread began 10/23/2016 12:07 pm by Christopher West | Last modified 10/24/2016 7:21 pm by Christopher West | 2683 views | 9 replies

Christopher WestCommunity Expert

shipping calculations are not correctly calculated

Hi, I have a shipping system that calculates basket based on weight X size X ChargeDelivery(ChargeDelivery is a checkbox on products table).

(Also please see screenshots)
In my eCart General tab:
Number format: 10,000.00

In my eCart Columns tab:
ChargeDelivery = (this is a number)
Width = (this is a number)
Height = (this is a number)
Depth = (this is a number)

In my Calculations tab:
TotalWeight = [Weight] * [Quantity] * [ChargeDelivery]
TotalSize = ([Width] * [Height] * [Depth]) * [Quantity] * [ChargeDelivery]

QUESTION 1: is the above how it should be set up for the type of calculation I want?

My PHP code:

php:
<?php

$rsShippingZone 
= new WA_MySQLi_RS("rsShippingZone",$ecartdb,1);
$rsShippingZone->setQuery("SELECT * FROM shippingzones WHERE ShippingZoneCode = ? AND ShippingZoneEnabled = 1");
$rsShippingZone->bindParam("s""".(isset($_SESSION['ZonePostCode'])?$_SESSION['ZonePostCode']:"")  ."""-1"); //colname
$rsShippingZone->execute();
?>
<?php
$rsDeliveryCost 
= new WA_MySQLi_RS("rsDeliveryCost",$ecartdb,1);
$rsDeliveryCost->setQuery("SELECT * FROM shippingcosts WHERE ShippingCostZone = ? AND ShippingCostEnabled = 1 AND ShippingCostWeightTo >= ? AND ShippingCostSize >= ? ORDER BY ShippingCostValue ASC");
$rsDeliveryCost->bindParam("s""".$rsShippingZone->getColumnVal("ShippingZone")  ."""-1"); //colname
$rsDeliveryCost->bindParam("s""".$eCart->TotalColumn("TotalWeight")  ."""-1"); //colname2
$rsDeliveryCost->bindParam("s""".$eCart->TotalColumn("TotalSize")  ."""-1"); //colname3
$rsDeliveryCost->execute();?>



QUESTION 2 : in the above PHP code, is that how I should be defining the SQL query?

On many test of the basket, the delivery cost ends up being FREE (so obviously its unable to select a SQL query) or the delivery cost ends up being £2.5 (max size 900cm3) Even though the basket totalsize is way over 900cm3).

Can you see any obvious mistakes in my logic?

Take a look at my test screenshots and compare to the shipping rules screenshot. if you look at test3.png its showing £12.99 for delivery cost by the total size is 13,585cm3 and totalweight is 3kg (so I cant figure out why its selecting £12.99 if you compare the sipping rules screenshot.

the code that displays FREE is:

php:
<?php if ($eCart->GetShipping() > 0) { ?>

           <strong>£<?php echo $eCart->GetShipping(); ?></strong>
           
           <?php } else { ?>
           <strong>Free</strong>
<?php ?>




***UPDATE***
I think it maybe the sql query as I done a test outputting some sessions variables based on the 2 recordsets above. and it only displays a value from my rsShippingZone recordset. On the test page nothing is displayed from my sessions I used to grab some bindings from the rsDeliveryCost. Which would suggest that this recordset sql query is returning 0 results. Not sure why though?

I edited the recordset to the following and I am getting better results....but does the logic make sense as I remember Ray you suggested using >= and ASC for order by.

php:
<?php

$rsDeliveryCost 
= new WA_MySQLi_RS("rsDeliveryCost",$ecartdb,1);
$rsDeliveryCost->setQuery("SELECT * FROM shippingcosts WHERE ShippingCostZone = ? AND ShippingCostWeightTo <= ? AND ShippingCostSize <= ? ORDER BY ShippingCostValue DESC");
$rsDeliveryCost->bindParam("s""".$rsShippingZone->getColumnVal("ShippingZone")  ."""-1"); //colname
$rsDeliveryCost->bindParam("s""".$eCart->TotalColumn("TotalWeight")  ."""-1"); //colname2
$rsDeliveryCost->bindParam("s""".$eCart->TotalColumn("TotalSize")  ."""-1"); //colname3
$rsDeliveryCost->execute();?>



Chris

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