Snoopy Posted February 11, 2019 Share (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 February 11, 2019 by Snoopy Quote Link to post
Patrick Posted February 11, 2019 Share (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 February 11, 2019 by Patrick 1 Quote Link to post
Snoopy Posted February 11, 2019 Author Share Ok thank you, I just basic knowledge in php. Your answer is cool Quote Link to post
Patrick Posted February 11, 2019 Share Info a little mistake : $shipping_weight = CLICSHOPPING_ProductsCommon->getProductsWeight(); Quote Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.