Magneto 2: Need to remove decimal from price on product detail page
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I want to remove the decimal in price on product details page. Although it removes in listing page, but still showing decimal in discount and final price on product details page.
magento2 price product-detail-page
add a comment |
I want to remove the decimal in price on product details page. Although it removes in listing page, but still showing decimal in discount and final price on product details page.
magento2 price product-detail-page
add a comment |
I want to remove the decimal in price on product details page. Although it removes in listing page, but still showing decimal in discount and final price on product details page.
magento2 price product-detail-page
I want to remove the decimal in price on product details page. Although it removes in listing page, but still showing decimal in discount and final price on product details page.
magento2 price product-detail-page
magento2 price product-detail-page
edited 10 mins ago
Kirti Nariya
1,252416
1,252416
asked Jan 21 at 9:21
AneesAnees
15712
15712
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The best way I could find is to change the priceFormat
function from Magento_Catolag/js/price-utils.js
inside my priceBox.js
, so in your requirejs-config.js
var config = {
"map": {
"*": {
"priceBox" : "Vendor_ModuleName/js/price-box"
}
}
};
Copy the whole Magento_Catalog/js/price-box.js
to your Vendor/ModuleName/view/frontend/web/js/price-box.js
and after the use strict
add:
var globalPriceFormat = {
requiredPrecision: 2,
integerRequired: 1,
decimalSymbol: ',',
groupSymbol: ',',
groupLength: ','
};
Under this copy the formatPrice function
from price-utils.js
Change:
function formatPrice(amount, format, isShowSign) {
var s = '',
precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
To
function formatPriceHack(amount, format, isShowSign) {
var s = '',
precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
Also comment:
//precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;
And change:
i = stringPad('0', pad) + i;
To inside formatPriceHack:
i = utils.strPad('0', pad) + i;
And last, change inside the reloadPrice
function from priceBox
:
price.formatted = utils.formatPrice(price.final, priceFormat);
To:
price.formatted = formatPriceHack(price.final, priceFormat);
That's it.
add a comment |
Create file and use this code :
=> From :
vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml
=> To :
app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml
this file is defined from MagentoFrameworkPricingRenderAmount
The price itself is coming from this call:
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php
)
Update line no 24
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
To
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>
You need to override
vendor/magento/module-catalog/view/base/web/js/price-utils.js
To
app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js
and change the value of precision on line 38:
var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,
To
var precision = 0,
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258530%2fmagneto-2-need-to-remove-decimal-from-price-on-product-detail-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The best way I could find is to change the priceFormat
function from Magento_Catolag/js/price-utils.js
inside my priceBox.js
, so in your requirejs-config.js
var config = {
"map": {
"*": {
"priceBox" : "Vendor_ModuleName/js/price-box"
}
}
};
Copy the whole Magento_Catalog/js/price-box.js
to your Vendor/ModuleName/view/frontend/web/js/price-box.js
and after the use strict
add:
var globalPriceFormat = {
requiredPrecision: 2,
integerRequired: 1,
decimalSymbol: ',',
groupSymbol: ',',
groupLength: ','
};
Under this copy the formatPrice function
from price-utils.js
Change:
function formatPrice(amount, format, isShowSign) {
var s = '',
precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
To
function formatPriceHack(amount, format, isShowSign) {
var s = '',
precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
Also comment:
//precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;
And change:
i = stringPad('0', pad) + i;
To inside formatPriceHack:
i = utils.strPad('0', pad) + i;
And last, change inside the reloadPrice
function from priceBox
:
price.formatted = utils.formatPrice(price.final, priceFormat);
To:
price.formatted = formatPriceHack(price.final, priceFormat);
That's it.
add a comment |
The best way I could find is to change the priceFormat
function from Magento_Catolag/js/price-utils.js
inside my priceBox.js
, so in your requirejs-config.js
var config = {
"map": {
"*": {
"priceBox" : "Vendor_ModuleName/js/price-box"
}
}
};
Copy the whole Magento_Catalog/js/price-box.js
to your Vendor/ModuleName/view/frontend/web/js/price-box.js
and after the use strict
add:
var globalPriceFormat = {
requiredPrecision: 2,
integerRequired: 1,
decimalSymbol: ',',
groupSymbol: ',',
groupLength: ','
};
Under this copy the formatPrice function
from price-utils.js
Change:
function formatPrice(amount, format, isShowSign) {
var s = '',
precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
To
function formatPriceHack(amount, format, isShowSign) {
var s = '',
precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
Also comment:
//precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;
And change:
i = stringPad('0', pad) + i;
To inside formatPriceHack:
i = utils.strPad('0', pad) + i;
And last, change inside the reloadPrice
function from priceBox
:
price.formatted = utils.formatPrice(price.final, priceFormat);
To:
price.formatted = formatPriceHack(price.final, priceFormat);
That's it.
add a comment |
The best way I could find is to change the priceFormat
function from Magento_Catolag/js/price-utils.js
inside my priceBox.js
, so in your requirejs-config.js
var config = {
"map": {
"*": {
"priceBox" : "Vendor_ModuleName/js/price-box"
}
}
};
Copy the whole Magento_Catalog/js/price-box.js
to your Vendor/ModuleName/view/frontend/web/js/price-box.js
and after the use strict
add:
var globalPriceFormat = {
requiredPrecision: 2,
integerRequired: 1,
decimalSymbol: ',',
groupSymbol: ',',
groupLength: ','
};
Under this copy the formatPrice function
from price-utils.js
Change:
function formatPrice(amount, format, isShowSign) {
var s = '',
precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
To
function formatPriceHack(amount, format, isShowSign) {
var s = '',
precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
Also comment:
//precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;
And change:
i = stringPad('0', pad) + i;
To inside formatPriceHack:
i = utils.strPad('0', pad) + i;
And last, change inside the reloadPrice
function from priceBox
:
price.formatted = utils.formatPrice(price.final, priceFormat);
To:
price.formatted = formatPriceHack(price.final, priceFormat);
That's it.
The best way I could find is to change the priceFormat
function from Magento_Catolag/js/price-utils.js
inside my priceBox.js
, so in your requirejs-config.js
var config = {
"map": {
"*": {
"priceBox" : "Vendor_ModuleName/js/price-box"
}
}
};
Copy the whole Magento_Catalog/js/price-box.js
to your Vendor/ModuleName/view/frontend/web/js/price-box.js
and after the use strict
add:
var globalPriceFormat = {
requiredPrecision: 2,
integerRequired: 1,
decimalSymbol: ',',
groupSymbol: ',',
groupLength: ','
};
Under this copy the formatPrice function
from price-utils.js
Change:
function formatPrice(amount, format, isShowSign) {
var s = '',
precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
To
function formatPriceHack(amount, format, isShowSign) {
var s = '',
precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;
Also comment:
//precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;
And change:
i = stringPad('0', pad) + i;
To inside formatPriceHack:
i = utils.strPad('0', pad) + i;
And last, change inside the reloadPrice
function from priceBox
:
price.formatted = utils.formatPrice(price.final, priceFormat);
To:
price.formatted = formatPriceHack(price.final, priceFormat);
That's it.
answered Jan 21 at 10:16
gemig_holgemig_hol
591119
591119
add a comment |
add a comment |
Create file and use this code :
=> From :
vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml
=> To :
app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml
this file is defined from MagentoFrameworkPricingRenderAmount
The price itself is coming from this call:
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php
)
Update line no 24
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
To
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>
You need to override
vendor/magento/module-catalog/view/base/web/js/price-utils.js
To
app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js
and change the value of precision on line 38:
var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,
To
var precision = 0,
add a comment |
Create file and use this code :
=> From :
vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml
=> To :
app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml
this file is defined from MagentoFrameworkPricingRenderAmount
The price itself is coming from this call:
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php
)
Update line no 24
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
To
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>
You need to override
vendor/magento/module-catalog/view/base/web/js/price-utils.js
To
app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js
and change the value of precision on line 38:
var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,
To
var precision = 0,
add a comment |
Create file and use this code :
=> From :
vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml
=> To :
app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml
this file is defined from MagentoFrameworkPricingRenderAmount
The price itself is coming from this call:
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php
)
Update line no 24
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
To
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>
You need to override
vendor/magento/module-catalog/view/base/web/js/price-utils.js
To
app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js
and change the value of precision on line 38:
var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,
To
var precision = 0,
Create file and use this code :
=> From :
vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml
=> To :
app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml
this file is defined from MagentoFrameworkPricingRenderAmount
The price itself is coming from this call:
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php
)
Update line no 24
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
To
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>
You need to override
vendor/magento/module-catalog/view/base/web/js/price-utils.js
To
app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js
and change the value of precision on line 38:
var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,
To
var precision = 0,
answered Jan 21 at 10:29
Rohan HapaniRohan Hapani
7,04631865
7,04631865
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258530%2fmagneto-2-need-to-remove-decimal-from-price-on-product-detail-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown