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; ?>

Anees
  • 634
  • 8
  • 24

3 Answers3

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

Rakesh Donga
  • 5,344
  • 2
  • 24
  • 57
VDC
  • 461
  • 2
  • 9
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"/>
Sejal Shah
  • 2,141
  • 1
  • 16
  • 46
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
?>
Ronak Rathod
  • 6,322
  • 17
  • 42