0

I am using shipping method in Magento2 my website.but this shipping method only two weight unit support so I want three weight unit support. my code is below, so help me

public function getStoreWeightUnit($storeId)
    {
        return $this->scopeConfig->getValue(
            'general/locale/weight_unit',
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $storeId
       // ) == 'lbs' ? 'LBS' : 'KILOGRAM';
        ) == 'grams' ? 'GRAMS' :'KILOGRAM':'kbs' ? 'lbs':'LBS' ;
    }

1 Answer 1

1

public function getStoreWeightUnit($storeId) {

$weightUnit =$this->scopeConfig->getValue( 'general/locale/weight_unit', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);

$unit = ($weightUnit == 'grams') ? 'GRAMS' : (($weightUnit == 'kbs') ? 'KILOGRAM' : 'LBS');

return $unit;

}

4
  • Let me know if any issues
    – mohith
    Commented Apr 2, 2019 at 12:25
  • ok i am now check and update you sir thank you Commented Apr 2, 2019 at 12:36
  • this code is helpfull to me thank you sir Commented Apr 2, 2019 at 12:55
  • No issues let me if any issues
    – mohith
    Commented Apr 2, 2019 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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