close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

excluding certain products from delivery calculation

Thread began 9/06/2016 4:44 pm by Christopher West | Last modified 9/13/2016 6:55 pm by Christopher West | 1019 views | 13 replies

Christopher WestCommunity Expert

I have narrowed it down to these in my recordset:

$rsDeliveryCost->bindParam("s", "".$eCart->DisplayInfo("TotalWeight") ."", "-1"); //colname2
$rsDeliveryCost->bindParam("s", "".$eCart->DisplayInfo("TotalSize") ."", "-1"); //colname3

I should have written it with "TotalColumn" like:

$rsDeliveryCost->bindParam("s", "".$eCart->TotalColumn("TotalWeight") ."", "-1"); //colname2
$rsDeliveryCost->bindParam("s", "".$eCart->TotalColumn("TotalSize") ."", "-1"); //colname3

Update: Hmm still not working as expected as I needed to add it some code so that it takes into account if a product is flagged for "ProductFreeDelivery" and "ProductCollectionOnly" the calculation of the totalweight and totalsize seem to be ok. but its not calculating the correct delivery cost.

What I did was in the eCartObject Shipping Tab was add these rules:
EstimatedDelivery
If Session variable exists: EstimatedDeliveryCost
AND SubTotal of ProductFreeDelivery == 1
AND SubTotal of ProductCollection == 1
Create a flat rate shipping of <?php echo $_SESSION['EstimatedDeliveryCost']; ?>

Could it be my columns in eCart?
TotalWeight = [Weight] * [Quantity] * [ProductCollectionOnly] * [ProductFreeDelivery]
TotalSize = ([Width] * [Height] * [Depth]) * [Quantity] * [ProductCollectionOnly] * [ProductFreeDelivery]

I have attached 2 files in case you can see the problem in there?

When I added some products in the basket - I chose 1 produce that I know should be excluded in the delivery cost (so the results were correct in showing me totalweight and totalsize)
And then I added multiple quantities of a product that I know should be included in the delivery calculation.

Was I correct in putting the conditions of the 2 columns in my shipping rules?
I was thinking that in the shipping rules I should have used:
AND Number of items with ProductFreeDelivery has a value of 1 is = a value of 1
AND Number of items with ProductCollectionOnly has a value of 1 is = a value of 1
But im sure the above didnt work either?

Its almost working, so just need to get over this hurdle in my logic?

I kinda feel that maybe I should be placing the condition in my recordset somewhere, but I am a little lost to where/how:

php:
<?php

$rsShippingZone 
= new WA_MySQLi_RS("rsShippingZone",$ecartdb,1);
$rsShippingZone->setQuery("SELECT * FROM shippingzones WHERE ShippingZoneCode = ?");
$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 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();?>
<?php
@session_start();
if(
"" == "")     {
    
    if (
"".(WA_getSavedFormValue("checkoutform","deliverymethod"))  ."" != "Shop Collection") {  // WebAssist Show If
    
$_SESSION["EstimatedDeliveryCost"] = "".($rsDeliveryCost->getColumnVal("ShippingCostValue"))  ."";
    
    } 
    else {
    
$_SESSION["EstimatedDeliveryCost"] = 0;        
    } 
    
}
?>



I just did a SQL test in phpMyAdmin and its NOT returning the correct result

SELECT * FROM shippingcosts WHERE ShippingCostZone = 'LOCAL' AND ShippingCostWeightTo <= 30 AND ShippingCostSize <= 3000 ORDER BY ShippingCostValue DESC

Screenshot of DB

(Note: I think maybe I should be using >= (rather than <=)

Would this make sense in what Im trying to achieve? to me its sounds wrong since im suggesting that the database value is greater or equal to the basket value..

php:
$rsDeliveryCost->setQuery("SELECT * FROM shippingcosts WHERE ShippingCostZone = ? AND ShippingCostWeightTo >= ? AND ShippingCostSize >= ? ORDER BY ShippingCostValue ASC");


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