How to get decimal value of weight in mini cart?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
How to get decimal value of weight in mini cart
.
I need to display only 2 decimals 11.00
instead of 11.0000
magento2 magento-2.1.7 mini-cart
 |Â
show 3 more comments
up vote
1
down vote
favorite
How to get decimal value of weight in mini cart
.
I need to display only 2 decimals 11.00
instead of 11.0000
magento2 magento-2.1.7 mini-cart
you want weight value as like 11.00, right ?
– Aditya Shah
1 hour ago
yeah its script had written in knockoutjs Aditya Shah
– trilok kumar
1 hour ago
Can you please add your phtml & js file code here ?
– Rohan Hapani
32 mins ago
<strong class="product-item-Weight"> <!-- ko if: weight --> <div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + weight * qty "></div> <!-- /ko --> </strong>
– trilok kumar
30 mins ago
1
Yeah :D But, it's knockout. So, It's different que than I gave all answer.
– Rohan Hapani
17 mins ago
 |Â
show 3 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
How to get decimal value of weight in mini cart
.
I need to display only 2 decimals 11.00
instead of 11.0000
magento2 magento-2.1.7 mini-cart
How to get decimal value of weight in mini cart
.
I need to display only 2 decimals 11.00
instead of 11.0000
magento2 magento-2.1.7 mini-cart
magento2 magento-2.1.7 mini-cart
edited 12 mins ago
asked 1 hour ago


trilok kumar
1168
1168
you want weight value as like 11.00, right ?
– Aditya Shah
1 hour ago
yeah its script had written in knockoutjs Aditya Shah
– trilok kumar
1 hour ago
Can you please add your phtml & js file code here ?
– Rohan Hapani
32 mins ago
<strong class="product-item-Weight"> <!-- ko if: weight --> <div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + weight * qty "></div> <!-- /ko --> </strong>
– trilok kumar
30 mins ago
1
Yeah :D But, it's knockout. So, It's different que than I gave all answer.
– Rohan Hapani
17 mins ago
 |Â
show 3 more comments
you want weight value as like 11.00, right ?
– Aditya Shah
1 hour ago
yeah its script had written in knockoutjs Aditya Shah
– trilok kumar
1 hour ago
Can you please add your phtml & js file code here ?
– Rohan Hapani
32 mins ago
<strong class="product-item-Weight"> <!-- ko if: weight --> <div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + weight * qty "></div> <!-- /ko --> </strong>
– trilok kumar
30 mins ago
1
Yeah :D But, it's knockout. So, It's different que than I gave all answer.
– Rohan Hapani
17 mins ago
you want weight value as like 11.00, right ?
– Aditya Shah
1 hour ago
you want weight value as like 11.00, right ?
– Aditya Shah
1 hour ago
yeah its script had written in knockoutjs Aditya Shah
– trilok kumar
1 hour ago
yeah its script had written in knockoutjs Aditya Shah
– trilok kumar
1 hour ago
Can you please add your phtml & js file code here ?
– Rohan Hapani
32 mins ago
Can you please add your phtml & js file code here ?
– Rohan Hapani
32 mins ago
<strong class="product-item-Weight"> <!-- ko if: weight --> <div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + weight * qty "></div> <!-- /ko --> </strong>
– trilok kumar
30 mins ago
<strong class="product-item-Weight"> <!-- ko if: weight --> <div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + weight * qty "></div> <!-- /ko --> </strong>
– trilok kumar
30 mins ago
1
1
Yeah :D But, it's knockout. So, It's different que than I gave all answer.
– Rohan Hapani
17 mins ago
Yeah :D But, it's knockout. So, It's different que than I gave all answer.
– Rohan Hapani
17 mins ago
 |Â
show 3 more comments
3 Answers
3
active
oldest
votes
up vote
2
down vote
accepted
For that, You need to add one custom function and pass your precision value and weight value. Add this below code in your html file :
<strong class="product-item-Weight">
<!-- ko if: weight -->
<div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + getWeight(2,weight * qty) ">
</div>
<!-- /ko -->
</strong>
Now, create getWeight() function in your knockout file inside Component.extend :
getWeight : function(precision,WeightValue)
var self = this;
return WeightValue / Math.pow(10, self.precision());
,
Now, refresh your html and knockout js file and check it.
Hope, It maybe helpful for you.
1
+1 :) i knew you will find
– Aditya Shah
5 mins ago
Thanks bro :) @AdityaShah
– Rohan Hapani
2 mins ago
Where should i create getWeight() function in your knockout file inside Component.extend Rohan Hapani
– trilok kumar
1 min ago
add a comment |Â
up vote
1
down vote
you can use number_format
function like this in minicart template file-
number_format($weight, 2, '.', '');
script had written in knockoutjs Shashank Kumrawat
– trilok kumar
1 hour ago
add a comment |Â
up vote
1
down vote
JS:
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
PHP:
$value = "11.0000";
$result = bcadd($value , 0, 2);
echo $result ; // 11.00
Update:
You can create a block, you put your js inside, then you bind that block in your knockoutjs
1. <?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
2. web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
3. custom.phtml
<script type="text/javascript">
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
</script>
Update2:
app/design/frontend/Vendor/theme/Magento_Search/view/frontend/templates/form.mini.phtml
<?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
script had written in knockoutjs PRINCE
– trilok kumar
1 hour ago
Check my update, I don't tested it but I think it should work
– PRINCE
59 mins ago
web/template/somename.html my file location <div class="name-class" data-bind="html:js_block"></div> here how to get PRINCE
– trilok kumar
56 mins ago
Look my update2
– PRINCE
43 mins ago
I am not getting any value as update2 – PRINCE
– trilok kumar
38 mins ago
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
For that, You need to add one custom function and pass your precision value and weight value. Add this below code in your html file :
<strong class="product-item-Weight">
<!-- ko if: weight -->
<div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + getWeight(2,weight * qty) ">
</div>
<!-- /ko -->
</strong>
Now, create getWeight() function in your knockout file inside Component.extend :
getWeight : function(precision,WeightValue)
var self = this;
return WeightValue / Math.pow(10, self.precision());
,
Now, refresh your html and knockout js file and check it.
Hope, It maybe helpful for you.
1
+1 :) i knew you will find
– Aditya Shah
5 mins ago
Thanks bro :) @AdityaShah
– Rohan Hapani
2 mins ago
Where should i create getWeight() function in your knockout file inside Component.extend Rohan Hapani
– trilok kumar
1 min ago
add a comment |Â
up vote
2
down vote
accepted
For that, You need to add one custom function and pass your precision value and weight value. Add this below code in your html file :
<strong class="product-item-Weight">
<!-- ko if: weight -->
<div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + getWeight(2,weight * qty) ">
</div>
<!-- /ko -->
</strong>
Now, create getWeight() function in your knockout file inside Component.extend :
getWeight : function(precision,WeightValue)
var self = this;
return WeightValue / Math.pow(10, self.precision());
,
Now, refresh your html and knockout js file and check it.
Hope, It maybe helpful for you.
1
+1 :) i knew you will find
– Aditya Shah
5 mins ago
Thanks bro :) @AdityaShah
– Rohan Hapani
2 mins ago
Where should i create getWeight() function in your knockout file inside Component.extend Rohan Hapani
– trilok kumar
1 min ago
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
For that, You need to add one custom function and pass your precision value and weight value. Add this below code in your html file :
<strong class="product-item-Weight">
<!-- ko if: weight -->
<div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + getWeight(2,weight * qty) ">
</div>
<!-- /ko -->
</strong>
Now, create getWeight() function in your knockout file inside Component.extend :
getWeight : function(precision,WeightValue)
var self = this;
return WeightValue / Math.pow(10, self.precision());
,
Now, refresh your html and knockout js file and check it.
Hope, It maybe helpful for you.
For that, You need to add one custom function and pass your precision value and weight value. Add this below code in your html file :
<strong class="product-item-Weight">
<!-- ko if: weight -->
<div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + getWeight(2,weight * qty) ">
</div>
<!-- /ko -->
</strong>
Now, create getWeight() function in your knockout file inside Component.extend :
getWeight : function(precision,WeightValue)
var self = this;
return WeightValue / Math.pow(10, self.precision());
,
Now, refresh your html and knockout js file and check it.
Hope, It maybe helpful for you.
answered 7 mins ago


Rohan Hapani
3,96821459
3,96821459
1
+1 :) i knew you will find
– Aditya Shah
5 mins ago
Thanks bro :) @AdityaShah
– Rohan Hapani
2 mins ago
Where should i create getWeight() function in your knockout file inside Component.extend Rohan Hapani
– trilok kumar
1 min ago
add a comment |Â
1
+1 :) i knew you will find
– Aditya Shah
5 mins ago
Thanks bro :) @AdityaShah
– Rohan Hapani
2 mins ago
Where should i create getWeight() function in your knockout file inside Component.extend Rohan Hapani
– trilok kumar
1 min ago
1
1
+1 :) i knew you will find
– Aditya Shah
5 mins ago
+1 :) i knew you will find
– Aditya Shah
5 mins ago
Thanks bro :) @AdityaShah
– Rohan Hapani
2 mins ago
Thanks bro :) @AdityaShah
– Rohan Hapani
2 mins ago
Where should i create getWeight() function in your knockout file inside Component.extend Rohan Hapani
– trilok kumar
1 min ago
Where should i create getWeight() function in your knockout file inside Component.extend Rohan Hapani
– trilok kumar
1 min ago
add a comment |Â
up vote
1
down vote
you can use number_format
function like this in minicart template file-
number_format($weight, 2, '.', '');
script had written in knockoutjs Shashank Kumrawat
– trilok kumar
1 hour ago
add a comment |Â
up vote
1
down vote
you can use number_format
function like this in minicart template file-
number_format($weight, 2, '.', '');
script had written in knockoutjs Shashank Kumrawat
– trilok kumar
1 hour ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
you can use number_format
function like this in minicart template file-
number_format($weight, 2, '.', '');
you can use number_format
function like this in minicart template file-
number_format($weight, 2, '.', '');
answered 1 hour ago


Shashank Kumrawat
6311136
6311136
script had written in knockoutjs Shashank Kumrawat
– trilok kumar
1 hour ago
add a comment |Â
script had written in knockoutjs Shashank Kumrawat
– trilok kumar
1 hour ago
script had written in knockoutjs Shashank Kumrawat
– trilok kumar
1 hour ago
script had written in knockoutjs Shashank Kumrawat
– trilok kumar
1 hour ago
add a comment |Â
up vote
1
down vote
JS:
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
PHP:
$value = "11.0000";
$result = bcadd($value , 0, 2);
echo $result ; // 11.00
Update:
You can create a block, you put your js inside, then you bind that block in your knockoutjs
1. <?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
2. web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
3. custom.phtml
<script type="text/javascript">
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
</script>
Update2:
app/design/frontend/Vendor/theme/Magento_Search/view/frontend/templates/form.mini.phtml
<?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
script had written in knockoutjs PRINCE
– trilok kumar
1 hour ago
Check my update, I don't tested it but I think it should work
– PRINCE
59 mins ago
web/template/somename.html my file location <div class="name-class" data-bind="html:js_block"></div> here how to get PRINCE
– trilok kumar
56 mins ago
Look my update2
– PRINCE
43 mins ago
I am not getting any value as update2 – PRINCE
– trilok kumar
38 mins ago
add a comment |Â
up vote
1
down vote
JS:
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
PHP:
$value = "11.0000";
$result = bcadd($value , 0, 2);
echo $result ; // 11.00
Update:
You can create a block, you put your js inside, then you bind that block in your knockoutjs
1. <?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
2. web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
3. custom.phtml
<script type="text/javascript">
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
</script>
Update2:
app/design/frontend/Vendor/theme/Magento_Search/view/frontend/templates/form.mini.phtml
<?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
script had written in knockoutjs PRINCE
– trilok kumar
1 hour ago
Check my update, I don't tested it but I think it should work
– PRINCE
59 mins ago
web/template/somename.html my file location <div class="name-class" data-bind="html:js_block"></div> here how to get PRINCE
– trilok kumar
56 mins ago
Look my update2
– PRINCE
43 mins ago
I am not getting any value as update2 – PRINCE
– trilok kumar
38 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
JS:
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
PHP:
$value = "11.0000";
$result = bcadd($value , 0, 2);
echo $result ; // 11.00
Update:
You can create a block, you put your js inside, then you bind that block in your knockoutjs
1. <?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
2. web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
3. custom.phtml
<script type="text/javascript">
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
</script>
Update2:
app/design/frontend/Vendor/theme/Magento_Search/view/frontend/templates/form.mini.phtml
<?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
JS:
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
PHP:
$value = "11.0000";
$result = bcadd($value , 0, 2);
echo $result ; // 11.00
Update:
You can create a block, you put your js inside, then you bind that block in your knockoutjs
1. <?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
2. web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
3. custom.phtml
<script type="text/javascript">
var value = 11.0000;
var result = value.toFixed(2);
alert(result); // 11.00
</script>
Update2:
app/design/frontend/Vendor/theme/Magento_Search/view/frontend/templates/form.mini.phtml
<?php $jsBlock = echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("html/custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var js_block = <?php echo json_encode($jsBlock)?>;
</script>
web/template/somename.html
<div class="name-class" data-bind="html:js_block"></div>
edited 44 mins ago
answered 1 hour ago


PRINCE
6,6652935
6,6652935
script had written in knockoutjs PRINCE
– trilok kumar
1 hour ago
Check my update, I don't tested it but I think it should work
– PRINCE
59 mins ago
web/template/somename.html my file location <div class="name-class" data-bind="html:js_block"></div> here how to get PRINCE
– trilok kumar
56 mins ago
Look my update2
– PRINCE
43 mins ago
I am not getting any value as update2 – PRINCE
– trilok kumar
38 mins ago
add a comment |Â
script had written in knockoutjs PRINCE
– trilok kumar
1 hour ago
Check my update, I don't tested it but I think it should work
– PRINCE
59 mins ago
web/template/somename.html my file location <div class="name-class" data-bind="html:js_block"></div> here how to get PRINCE
– trilok kumar
56 mins ago
Look my update2
– PRINCE
43 mins ago
I am not getting any value as update2 – PRINCE
– trilok kumar
38 mins ago
script had written in knockoutjs PRINCE
– trilok kumar
1 hour ago
script had written in knockoutjs PRINCE
– trilok kumar
1 hour ago
Check my update, I don't tested it but I think it should work
– PRINCE
59 mins ago
Check my update, I don't tested it but I think it should work
– PRINCE
59 mins ago
web/template/somename.html my file location <div class="name-class" data-bind="html:js_block"></div> here how to get PRINCE
– trilok kumar
56 mins ago
web/template/somename.html my file location <div class="name-class" data-bind="html:js_block"></div> here how to get PRINCE
– trilok kumar
56 mins ago
Look my update2
– PRINCE
43 mins ago
Look my update2
– PRINCE
43 mins ago
I am not getting any value as update2 – PRINCE
– trilok kumar
38 mins ago
I am not getting any value as update2 – PRINCE
– trilok kumar
38 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f246449%2fhow-to-get-decimal-value-of-weight-in-mini-cart%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
you want weight value as like 11.00, right ?
– Aditya Shah
1 hour ago
yeah its script had written in knockoutjs Aditya Shah
– trilok kumar
1 hour ago
Can you please add your phtml & js file code here ?
– Rohan Hapani
32 mins ago
<strong class="product-item-Weight"> <!-- ko if: weight --> <div class="Approx-Weight" data-bind="html: 'Approx Weight : ' + weight * qty "></div> <!-- /ko --> </strong>
– trilok kumar
30 mins ago
1
Yeah :D But, it's knockout. So, It's different que than I gave all answer.
– Rohan Hapani
17 mins ago