![]() |
display the total weight on the view cart page
How do you display the total weight of all products on the "view cart" page?
|
if your refering to the products.tpl or products_t.tpl
Code:
{$products[product].shipping_freight} |
I am referring to the cart.php - I need to display the total weight of all products in the shopping cart. This needs to be displayed on the shopping cart page - cart.php
Quote:
|
display the total weight on the view cart page
Hi,
I have the same problem with kumar, any one has idea to show the total weight in view cart page? Thanks a lot. Regards, Andy X-cart 4.0.13 |
----------------------------------------------------------------------------------
In /shipping/shipping.php, add: Code:
$smarty->assign("total_weight_shipping",$total_weight_shipping); Code:
$total_weight_shipping = func_weight_shipping_products($products); Then, to call this simply edit /skin1/customer/main/cart_totals.tpl and place this wherever you want to show it: Code:
{$total_weight_shipping} |
display the total weight on the view cart page
Hi lookformeb,
It is great and it is working for me and that's what I want. Thanks a lot for your help. Regards, Andy X-cart 4.0.13 |
Re: display the total weight on the view cart page
Nice one lookformeb, that worked a treat. :D
I made it appear in the middle of 'Subtotal' & 'Shipping Cost' like so: http://www.arcadiaconsoles.co.uk/images/total_weight.jpg :D/ Now I need to figure out how to make it appear in the Invoice... |
Re: display the total weight on the view cart page
Moving to Custom Mods :)
|
Re: display the total weight on the view cart page
I also used this mod. Thank you, lookformeb.
I use grams for shipping, and the problem I have is that there is several decimal places. This is a little bit of overkill. Is there a way to round to a whole number? I modified my shipping.php file slightly to add 15% to the weight total, to allow for packing materials. Here is what it looks like, in case this is where I have to modify for rounding: $total_weight = 0; foreach ($products as $product) { if (@$product["deleted"]) continue; # for Advanced_Order_Management module if ( ($product["free_shipping"] == "Y" && ($config['Shipping']['free_shipping_weight_select'] != 'Y' || ($config['Shipping']['free_shipping_weight_select'] == 'Y' && !$ignore_freight))) || ($active_modules["Egoods"] && $product["distribution"] != "") || (!$ignore_freight && $config["Shipping"]["replace_shipping_with_freight"] == "Y" && $product["shipping_freight"] > 0) ) { continue; } $total_weight += $product["weight"] * $product["amount"]; } $total_weight *= 1.15; return $total_weight; |
Re: display the total weight on the view cart page
I also applied this to my cart and it works great!
Thanks! |
Re: display the total weight on the view cart page
Quote:
In /shipping/shipping.php, add: Code:
$smarty->assign("total_weight_shipping_valid", $total_weight_shipping_valid); Code:
$total_weight_shipping_valid = func_weight_shipping_products($cart['products'], true, $all_products_free_shipping, false); Then, to call this simply edit /skin1/customer/main/cart_totals.tpl and place this wherever you want to show it: Code:
{$total_weight_shipping_valid} |
Re: display the total weight on the view cart page
Nice one. For anyone intrested in layout I added this to skin1/main.css
Code:
.totals .total-wt { and used it this way in cart_totals.tpl (around line 191) Code:
the"g" is for grams BTW since I was too lazy to edit languages and put in a nice label, although I did for lbl_totalwt which you can do or just type in the text you want. Vixnfox |
Re: display the total weight on the view cart page
Hey vixnfox,
I didn't even add anything to the CSS layout. I just added this: Code:
<tr> |
Re: display the total weight on the view cart page
Any idea on how this can be achieved using XC v4.4.x?
Many Thanks |
Re: display the total weight on the view cart page
Quote:
To do this in 4.4.x - follow the previous instructions for 4.3.x, but instead of: shipping/shipping.php you need to be in: include/func/func.shipping.php |
Re: display the total weight on the view cart page
Thanks to everyone who contributed to the solution. I made a couple slight changes to accomplish this in 4.5.x using One Page Checkout.
In /shipping/shipping.php add Code:
$smarty->assign("total_weight_shipping_valid", $total_weight_shipping_valid); Code:
$total_weight_shipping_valid = func_weight_shipping_products($cart['products'], true, $all_products_free_shipping, false); I called it on /skin/common_files/modules/One_Page_Checkout/Summary/cart_totals.tpl by just inserting a row where I wanted it to display. Code:
<tr> |
Re: display the total weight on the view cart page
I'm struggling to get this to work on version 4.5.1. The file which includes the PHP code to amend is actually include/func/func.shipping.php, and I have done the following:
PHP Code:
And on the cart.tpl I have included this: HTML Code:
{$total_weight_shipping_valid} However nothing shows up. Any thoughts? |
Re: display the total weight on the view cart page
Are you wrapping your call in anything? If I take it out of the table, it does not display.
|
Re: display the total weight on the view cart page
Quote:
Do you mean the smarty code? I'm including it in the Cart template near the "Checkout" button at the moment, but my final intention is to do an if statement see if total weight is over 12, if not, then include a disabled Checkout button (since weight must be over 12 to proceed). |
Re: display the total weight on the view cart page
My bad, I thought you wanted to display information. I did something a while back that disabled specific shipping options based on extra field values of cart contents, but I really don't remember the details. I'm sure I found the instructions on the forum, it may help point you in the right direction.
If your only requirement is order total must be over 12 lbs, you could just set the minimum value on shipping options at 12 lbs and change the error label to read something like "Your order must be at least ..." The customer would not be able to check proceed without selecting a shipping method. If you did that, you may want to include the weight in the cart display. |
Re: display the total weight on the view cart page
Thanks for the advice drheath, however we want a visual display on the cart which tells them they need to have over 12 in weight in order to continue.
Anyone know how to achieve this mod in 4.5.1? |
Re: display the total weight on the view cart page
Well after about an hour of butting my head against my desk, I've realised why it wasn't working: because I wasn't logged in as a customer. The smarty variable gets assigned once the address is known.
Obviously not all customers will be logged in, so you need to select the "Presume that a not logged in customer is from the default country" checkbox in the general settings in order for this to work. |
Re: display the total weight on the view cart page
Nice, sometimes the simplest solutions are the best ones. Did you end up having to make any additional changes to the code other than the 2 you mentioned?
|
Re: display the total weight on the view cart page
Trying to figure out how to do this on 4.6.5 but QT decided to move shipping.php from /shipping... trying to find where they've moved it to.
Found it - include/func/func.shipping.php Interesting, QT have already included this bit for us: Code:
$smarty->assign("total_weight_shipping_valid", $total_weight_shipping_valid); Code:
<tr> after Code:
{if $cart.display_discounted_subtotal ne $cart.display_subtotal} |
All times are GMT -8. The time now is 08:53 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.