Jump to content
ClicShopping News Read more... ×
Sign in to follow this  
Snoopy

Weight configuration& conversion

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Info a little mistake :

 

$shipping_weight = CLICSHOPPING_ProductsCommon->getProductsWeight();

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

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