1

I have successfully remove price decimal from product listing but unable to remove it from product details page. How to remove it. enter image description here

<span class="price-container <?php /* @escapeNotVerified */ echo $block->getAdjustmentCssClasses() ?>"
    <?php echo $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
    <span class="price-label"><?php /* @escapeNotVerified */ echo $block->getDisplayLabel(); ?></span>
<?php endif; ?>
<span <?php if ($block->getPriceId()): ?> id="<?php /* @escapeNotVerified */ echo $block->getPriceId() ?>"<?php endif;?>
    <?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel()  . '"' : '' ?>
    data-price-amount="<?php /* @escapeNotVerified */ echo $block->getDisplayValue(); ?>"
    data-price-type="<?php /* @escapeNotVerified */ echo $block->getPriceType(); ?>"
    class="price-wrapper <?php /* @escapeNotVerified */ echo $block->getPriceWrapperCss(); ?>"
    <?php echo $block->getSchema() ? ' itemprop="price"' : '' ?>>
    <?php /* @escapeNotVerified */  //echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
    <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer(), 0) ?>
    <?php /* @escapeNotVerified */ //echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer(), 3) ?>
</span>
<?php if ($block->hasAdjustmentsHtml()): ?>
    <?php echo $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()): ?>
    <meta itemprop="priceCurrency" content="<?php /* @escapeNotVerified */ echo $block->getDisplayCurrencyCode()?>" />
<?php endif; ?>

3 Answers 3

1

For product page you also should modify next javascript:

/vendor/magento/module-catalog/view/base/web/js/price-utils.js

Overirde above file in our theme and on line 38 change

var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,

for

var precision = 0,

Hope this help! I found this in Ref

0
0

If you want to remove the price block totally, you can override and remove price block from catalog_product_view.xml:

<referenceBlock name="product.info.price" remove="true"/>
0

In PHP 2 Function For Conver Flot or Decimal Valuer To Int Value

intval() Function

<?php
echo intval(4.2);   //4
?>

round() Function

<?php 
echo rount(4.2)   //4
echo rount(4.9)   //5
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.