enter image description here

I want to display total products weight

(products weight* items quantity) in chekcout page shipping method lable beside.

2 Answers 2


You have in your module, in Model/Carrier the collectRates method with the parameter \Magento\Shipping\Model\Rate\Result $request and you can use this (int)$request->getPackageWeight().

I updated my answer

Below you have the module: You can see the screenshot here.

You need to create the module in app/code/VendorName/Shipping:

app/code/VendorName/Shipping/registration.php file:


If you want to to have the app/code/VendorName/Shipping/composer.json file:

    "name": "vendorname/module-shipping",
    "description": "",
    "type": "magento2-module",
    "license": "proprietary",
    "minimum-stability": "dev",
    "require": {},
    "autoload": {
        "files": [
        "psr-4": {
            "VendorName\\Shipping\\": ""

app/code/VendorName/Shipping/etc/module.xml file:

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="VendorName_Shipping" setup_version="1.0.0"/>

app/code/VendorName/Shipping/etc/config.xml file:

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
                <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg>

app/code/VendorName/Shipping/etc/adminhtml/system.xml file:

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <section id="carriers" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="1000" translate="label">
            <group id="shippingname" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
                <field id="active" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label" type="select">
                <field id="name" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label" type="text">
                    <label>Method Name</label>
                <field id="price" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="30" translate="label" type="text">
                    <validate>validate-number validate-zero-or-greater</validate>
                <field id="sort_order" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="40" translate="label" type="text">
                    <label>Sort Order</label>
                <field id="title" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="50" translate="label" type="text">
                <field id="sallowspecific" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="60" translate="label" type="select">
                    <label>Ship to Applicable Countries</label>
                <field id="specificcountry" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="70" translate="label" type="multiselect">
                    <label>Ship to Specific Countries</label>
                <field id="specificerrmsg" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="80" translate="label" type="textarea">
                    <label>Displayed Error Message</label>
  • What you have in Model ?
    – St3phan
    Sep 26, 2018 at 9:14
  • I will create an example for you
    – St3phan
    Sep 26, 2018 at 9:15
  • Please see my updated question, i have update exact position where i need to display Sep 26, 2018 at 9:21
  • Your screenshot is not the default design by Magento 2.1.7, it's very hard for me, but I can put the weight below of shipping method name.
    – St3phan
    Sep 26, 2018 at 19:00
  • Hi St3phan, its fine if its there alos you can provide me code please . Sep 27, 2018 at 4:31

First override the shipping method box on checkout page

Then you can get total weight of products of cart by \Magento\Checkout\Model\Cart class

With objectManager

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
$items = $cart->getQuote()->getAllItems();

$weight = 0;
foreach($items as $item) {
    $weight += ($item->getWeight() * $item->getQty()) ;        

echo $weight;

With Factory Method

protected $_cart;

public function __construct(
    \Magento\Checkout\Model\Cart $cartModel,
) {
    $this->_cart = $cartModel;

public function getTotalWeight()
    $items = $this->_cart->getQuote()->getAllItems();

    $weight = 0;
    foreach($items as $item) {
        $weight += ($item->getWeight() * $item->getQty()) ;        

    return $weight;
  • Thanks for comment, Please see my question, i have update exact position where i need to display Sep 26, 2018 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.