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

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;

}

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

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.