Skip to content

Commit

Permalink
Rewrite PDP price logic
Browse files Browse the repository at this point in the history
  • Loading branch information
srenon committed Oct 21, 2020
1 parent c0f3346 commit baede62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Block/Data/Product.php
Expand Up @@ -12,6 +12,7 @@
use Magento\Catalog\Block\Product\AbstractProduct;
use Magento\Catalog\Block\Product\Context;
use Magento\Catalog\Helper\Data;
use Magento\Catalog\Pricing\Price\FinalPrice;
use MagePal\GoogleTagManager\Block\DataLayer;
use MagePal\GoogleTagManager\DataLayer\ProductData\ProductProvider;
use MagePal\GoogleTagManager\Helper\Product as ProductHelper;
Expand Down Expand Up @@ -100,8 +101,12 @@ public function getPrice()
$price = 0;

/** @var $product ProductInterface */
if ($product = $this->getProduct()) {
$price = !$product->getSpecialPrice() ? $product->getPrice() : $product->getSpecialPrice();
if ($this->getProduct()) {
$price = $this->getProduct()
->getPriceInfo()
->getPrice(FinalPrice::PRICE_CODE)
->getAmount()
->getBaseAmount() ?: 0;
}

return $tm->formatPrice($price);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -40,7 +40,7 @@
"magepal/magento2-core":">1.1.0"
},
"type": "magento2-module",
"version": "2.5.1",
"version": "2.5.2",
"autoload": {
"files": [
"registration.php"
Expand Down

0 comments on commit baede62

Please sign in to comment.