Jump to content

Weight configuration& conversion


Recommended Posts

(edited)

Hello,

 

Inside the products admin page, There are 2 fields for the weight, one for the weight, one for the weight type.

my question is I want to make a module to display different weight type conversion.
Can I do that, or I make to write something to display the conversion.

Example : Kg => Lb

Edited by Snoopy
Link to post
(edited)

Hello @Snoopy

If you look inside the administration Configuration, you a weight menu where can add different weight conversation.

Now how to make that on the catalog !

Below the element can help you. This code allow you to convert all in Kg.

$CLICSHOPPING_Weight = Registry::get('Weight');
$CLICSHOPPING_ProductsCommon = Registry::get('ProductsCommon');

$defaultUnitWeight = SHIPPING_WEIGHT_UNIT; // 2 in the default configuration KG

shipping_weight = getProductsWeight

// Take only the kg 

// gr to kg
if ( $defaultUnitWeight == 1) { 
  $weight  = round($CLICSHOPPING_Weight->convert($shipping_weight, $defaultUnitWeight, 2), 3); 
} 

//Ounce to kg 
if ( $defaultUnitWeight == 3) { 
  $weight = round($CLICSHOPPING_Weight->convert($shipping_weight, $defaultUnitWeight, 2), 3); 
} 

//Ounce to kg 
if ( $defaultUnitWeight == 4) { 
  $weight = round($CLICSHOPPING_Weight->convert($shipping_weight, $defaultUnitWeight, 2), 3); 
}

echo $weight;

 

Edited by Patrick
  • Thanks 1
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use