Support » Plugin: WooCommerce » [Plugin: WooCommerce – excelling eCommerce] Woocommerce total cart weight

Viewing 11 replies - 1 through 11 (of 11 total)
  • Or Total Dimensions?

    Plugin Author Mike Jolley

    (@mikejolley)

    You’d need to loop the items and add it up through code. $woocommerce->cart->get_cart() should give you the items in an array.

    Hi can you share some example code, or which files to modify or please send a link to example code.
    Many thanks.

    Plugin Author Mike Jolley

    (@mikejolley)

    Actually, you can grab the cart weight from this variable: http://wcdocs.woothemes.com/apidocs/source-class-WC_Cart.html#24

    Override the totals template if you want to display the weight in the totals area:
    http://wcdocs.woothemes.com/codex/template-structure/

    Just copy template file you want to modify to yourtheme/woocommerce
    Keep folder structure for the file location.
    Wherever you want the weight to appear just type
    echo $woocommerce->cart->cart_contents_weight;
    in function context you have to globalise $woocommerce otherwise it won’t work e.g.
    function some_function() {
    global $woocommerce;
    echo $woocommerce->cart->cart_contents_weight;
    }

    Im trying with echo $woocommerce->cart->cart_contents_weight; on the template but it returns only 0 ???

    Plugin Author royho

    (@royho)

    You must have global $woocommerce; declared before you call that.

    Thanks that’s working.

    So mean how to retrieve total Weight in (kg) of all products in cart.
    For Example:

    ————————
    Cart Subtotal 24,49 €
    Order Total 24,49 €
    Products Weight: 100 kg

    I see that $woocommerce->cart->cart_contents_weight; return wrong data???

    Its return the total weight only of first product.

    If you have:

    1. Product1 – 300kg
    2. Product2 – 100kg

    $woocommerce->cart->cart_contents_weight; return only 300kg why ?

    hi everyone, i manage to show total weight using this code on cart/totals.php

    <tr class="total weight">
       <th><strong><?php _e('Total Weight', 'woocommerce'); ?></strong></th>
         <td><strong><?php
           $total_weight = $woocommerce->cart->cart_contents_weight;
           $total_weight .= ' '.get_option('woocommerce_weight_unit');
           echo $total_weight;
         ?></strong></td>
     </tr>

    anyhow to display total dimensions?

    AWD Weight/Country Shipping is ok but don´t count in the weight of the package. So if someone for example buys something so the total weight for the products article is let say 1800g, they will pay shipping costs for 1800g. But if the package is let say 450g, the total weight will be 2250g, which means I, as a seller must pay a lot more for the shipping than the costumer do. So that will not work. So I wonder if there is a plugin or a script I can put to your plugin AWD Weight/Country Shipping which will consider this (package weight) and count in the total weight for articles AND package in the cart for total shipping costs?

    1. One thing the plugin could calculate on is the articles volume (books in my case). The dimensions I can write in to woocommerce for each article as well as the weight. The weight the plugin AWD Weight/Country Shipping use, but not the dimensions information. The “article volume adding package weight” way of count is one way to go. As an administrator I could put in that if the volume is 60x21x60 mm = 75600 mm3 the calculator in the plugin AWD Weight/Country Shipping would put in an extra 250 g to the total weight (article + package) and so on. If the volume for the bookarticles increase the packagecosts would also increase of course.

    2. Another solution would be for the plugin AWD Weight/Country Shipping to first count the total weight for the articles, and then it could put that weight to one package weight so the total weight for the articles and package is correct. I as an administrator could of course put in values, let say if the total weight is let say 500g for the article the calculator can put to the total weight of package to 250g, so the total weight would be 500 +250g = 750g. Or an administrator could also put in this values: so the calculator would do like this: let say if the total weight is let say 1750g for the article the calculator can put to the total weight of package to 440g, so the total weight will be 1750 (Article weight) +440g (Package weight) = 2190g in total weight. The adding of “weight of package to article weight” is of course another way to go.

    As it is now I can only put in weight and country information. Could you fix the plugin AWD Weight/Country Shipping so an administrator also can write in package values so the total weight will be correct?

    Thanks for all tips and help.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: WooCommerce – excelling eCommerce] Woocommerce total cart weight’ is closed to new replies.