close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Sum TotalWeight at Checkout

Thread began 10/02/2009 8:22 pm by ninetyplus | Last modified 11/30/2009 4:45 pm by ryanteets270615 | 5131 views | 10 replies |

ninetyplus

Sum TotalWeight at Checkout

I've implemented a way for my customer to choose different weights of roasted coffee (1lb, 2lb and 5lb bags) through a menu/list then select the quantity of each item. I've made the weight value unique in the eCart column but when I bind the TotalWeight value to the checkout page to show the total weight of all orders, the value that appears is from the first item in the cart. For example, If I have two 5lb bags of coffee A, one 2lb bag of Coffee A and three 5lb bags of Coffee B, the TotalWeight will only show the sum of the first item in the cart which is coffee A (10lbs). Is there a calculation that I can create to sum up all of the weight values? I'm using PHP.

Thanks!

Steve

Sign in to reply to this post

Eric Mittman

In order to get the subtotal for the entire column you will need to use the binding within the TotalColumn function like this:

php:
$WA_Store_Cart->TotalColumn("TotalWeight")



Just use this in place of where you are just using TotalWeight, you may need to update the name of the cart object to your own.

Sign in to reply to this post

rob_wilkins385013

Same issue here. can you please be more specific?

exactly where and in which file would I place that code. Sorry to be a pain, but this would be a great help. Im not really sure how to 'bind' something.

Thanks.

Sign in to reply to this post

Eric Mittman

The original user was mentioning that he put the binding for the total weight on the cart display page to display the total weight. The problem was that this will only display the total weight for the first item in the cart, to get all of the items weight you would use the total column around it like the example code.

You would use this anywhere that you would like to have the total weight of the entire cart and not just the first item in the cart. The update would be make in the code view, you can just wrap the function around the total weight value you already have.

Sign in to reply to this post

Kevin373660

Total Shipping Weight Function

I am using 4.5.2 with php and MySQL.

I do not seem to have a math "fuction" that Eric mentioned, on any of may eCart generated pages to calulate the combined TotalWeight for all the items in the cart. I can echo the value on the page and it only displays the weight of the first item. I am shipping with UPS with automatic rate lookup. The rate returns correct for the TotalWeight value which is bound to their configuration setting.

Does anyone have a copy of the code block that adds the weights of all the items that are in the cart and the code (mentioned in this post) to assign its value the the TotalWeight cart->DispalyInfo("TotalWeight")???

Sign in to reply to this post

Eric Mittman

In eCart the column that holds the total weight for a single item is called TotalWeight. Each item in the cart will have a value for this binding. If you would like to have the combined total weight of the entire cart you would just use the total column function like this:

php:
$WA_Store_Cart->TotalColumn("TotalWeight")



You would of course need to update this to be the name of your cart. If this is not what you are looking for please explain a little more about what you are trying to accomplish.

Sign in to reply to this post

Kevin373660

This post has been deleted.

Kevin373660

Ok, I got it to echo the value on the cart page and I assume that you could remove the echo part, with the following code:

<?php echo ($MyCartName->TotalColumn("TotalWeight")); ?>


THEN on the confirm page changed the code for the shipper to:

$Shipping_PackageArray[$Shipping_PackageIndex]["PackageWeight"] = "".$MyCartName->TotalColumn("TotalWeight") ."";

This will total all of the item weights if shipping in one box. I used an average size of shipping box as most costs are mainly factored by weight.

Sign in to reply to this post

Kevin373660

For digial goods, Zero combined shipping weight = no cost

For the benifit of others in the formum that may need this.

In my table I have defined the weight value for each item. If the item/product does not require shipping the weight value is set to =0 (zero).

However, when testing with a single item that has a zero weight value, the base rate for a minimum 1lb box is returned.

************* confirm.php - by pass the UPS if weight is 0 (zero) *************

if ($_SERVER["REQUEST_METHOD"] == "POST" && $ClubCartUSA->TotalColumn("TotalWeight") > 0) {

**********************

Additional work is required to both the checkout and confirm pages to hide the shipping sections. I just havn't got that far yet.

Sign in to reply to this post

Eric Mittman

Nice work with the conditional shipping server behavior. When it comes to the checkout page and confirm pages you can use your same logic to only show these parts when there is a weight in the cart. If you have server validations occurring for the shipping info from the checkout page then you can use your if statement to prevent these from occurring if there is no weight.

Sign in to reply to this post
loading

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