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)

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.


All times are GMT -8. The time now is 07:56 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.