X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   display the total weight on the view cart page (https://forum.x-cart.com/showthread.php?t=5315)

kumar 11-23-2003 12:10 PM

display the total weight on the view cart page
 
How do you display the total weight of all products on the "view cart" page?

B00MER 11-24-2003 09:14 PM

if your refering to the products.tpl or products_t.tpl

Code:

{$products[product].shipping_freight}

kumar 11-25-2003 07:06 AM

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:

Originally Posted by B00MER
if your refering to the products.tpl or products_t.tpl

Code:

{$products[product].shipping_freight}


andyng 07-05-2005 06:26 AM

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

lookformeb 07-25-2005 04:23 PM

----------------------------------------------------------------------------------
In /shipping/shipping.php, add:
Code:

$smarty->assign("total_weight_shipping",$total_weight_shipping);
after:
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}

andyng 07-25-2005 07:31 PM

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

just wondering 11-18-2006 05:13 AM

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

balinor 11-18-2006 05:54 AM

Re: display the total weight on the view cart page
 
Moving to Custom Mods :)

Rob_D 09-20-2008 07:26 PM

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;

kmjperformance 01-07-2009 04:39 PM

Re: display the total weight on the view cart page
 
I also applied this to my cart and it works great!

Thanks!

just wondering 03-05-2010 08:53 AM

Re: display the total weight on the view cart page
 
Quote:

Originally Posted by lookformeb
----------------------------------------------------------------------------------
In /shipping/shipping.php, add:
Code:

$smarty->assign("total_weight_shipping",$total_weight_shipping);
after:
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}

This is slightly different on 4.3.1:

In /shipping/shipping.php, add:
Code:

$smarty->assign("total_weight_shipping_valid", $total_weight_shipping_valid);
after:
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}

vixnfox 03-05-2010 06:00 PM

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 {
  white-space: nowrap;
  color: #cccccc;
  font-weight: bold;
  text-align: left;
}


and used it this way in cart_totals.tpl (around line 191)

Code:


  <div class="right-box">
    <table cellspacing="0" class="totals" summary="{$lng.lbl_total|escape}">
  <tr>
  <td class="total-wt">{$lng.lbl_totalwt}</td>
  <td class="total-name">{$total_weight_shipping_valid}g</td>
  </tr>

      <tr>
        <td class="total-name">{$lng.lbl_subtotal}:</td>
        <td class="total-value">{include file="currency.tpl" value=$cart.display_subtotal}</td>
        <td class="total-alt-value">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$cart.display_subtotal}</td>
 
      </tr>


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

just wondering 03-08-2010 08:03 AM

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>
        <td class="total-name">{$lng.lbl_total_weight}:</td>
        <td class="total-value">{$total_weight_shipping_valid} KG</td>
      </tr>

& made the "lbl_total_weight" Label and it worked a treat. :D

chamberinternet 07-11-2011 01:44 AM

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

pauldodman 11-17-2011 02:30 AM

Re: display the total weight on the view cart page
 
Quote:

Originally Posted by chamberinternet
Any idea on how this can be achieved using XC v4.4.x?


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

drheath 12-18-2012 09:30 AM

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);
after
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>
      <td class="total-name">{$lng.lbl_weight}:</td>
      <td class="total-value">{$total_weight_shipping_valid} lbs</td>
    </tr>


dmpinder 02-25-2013 09:12 AM

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:

$total_weight_shipping_valid func_weight_shipping_products($cart['products'], true$all_products_free_shippingfalse);
    
$smarty->assign('total_weight_shipping_valid'$total_weight_shipping_valid); 


And on the cart.tpl I have included this:

HTML Code:

{$total_weight_shipping_valid}

However nothing shows up. Any thoughts?

drheath 02-25-2013 09:51 AM

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.

dmpinder 02-25-2013 10:01 AM

Re: display the total weight on the view cart page
 
Quote:

Originally Posted by drheath
Are you wrapping your call in anything? If I take it out of the table, it does not display.


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

drheath 02-25-2013 10:28 AM

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.

dmpinder 04-02-2013 07:48 AM

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?

dmpinder 04-02-2013 08:09 AM

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.

drheath 04-02-2013 08:31 AM

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?

Lloyd Hosting 11-23-2014 05:36 AM

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);
So I added this to /skin/common_files/modules/One_Page_Checkout/Summary/cart_totals.tpl
Code:

    <tr>
      <td class="total-name">Total Weight:</td>
      <td class="total-value">{$total_weight_shipping_valid}g</td>
    </tr>


after
Code:

  {if $cart.display_discounted_subtotal ne $cart.display_subtotal}
    <tr>
      <td class="total-name">{$lng.lbl_discounted_subtotal}:</td>
      <td class="total-value">{currency value=$cart.display_discounted_subtotal}</td>
    </tr>
  {/if}



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.