[Fix It Series] Total Price In Wishlist Page Is $0.00 In Magento 2

magento error price is 0.00 in wishlist page

PROBLEM

The total price for all products is wrong in the Wishlist Page in Magento 2. Although each product has its own price, the total price equals $0.00.

SOLUTIONS

Let’s follow the following steps:

  • 1st step: Create folder app\code\Tigren\Wishlist
  • 2nd step: Create folder etc
  • 3rd step: Create folder Pricing\ConfiguredPrice

Code:

Create di.xml in etc

<?xml version="1.0"?>
<!--
/**
 * @copyright Copyright (c) 2017 www.tigren.com
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct" type="Tigren\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct" />
</config>

Create Module.xml in etc

<?xml version="1.0"?>
<!--
/**
 * @copyright Copyright (c) 2017 www.tigren.com
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Tigren_Wishlist" setup_version="0.0.1" >
    </module>
</config>

Create ConfigurableProduct.php in Pricing\ConfiguredPrice

<?php
/**
 * @copyright Copyright (c) 2017 www.tigren.com
 */
namespace Tigren\Wishlist\Pricing\ConfiguredPrice;

class ConfigurableProduct extends \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct
{
    public function getValue()
    {
        /** @var \Magento\Wishlist\Model\Item\Option $customOption */
        $customOption = $this->getProduct()->getCustomOption('simple_product');
        $product = $customOption ? $customOption->getProduct() : $this->getProduct();
        $price = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getValue();
        return max(0, $price);
    }
}

Create composer.json

{
  "name": "tigren/magento2-module-wishlist",
  "description": "developer by clay - tigren",
  "require": {
    "php": "~7.0.0"
  },
  "type": "magento2-module",
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "autoload": {
    "files": [
      "registration.php"
    ],
    "psr-4": {
      "Tigren\\Wishlist\\": ""
    }
  }
}

Create registration.php

<?php
/**
 * @copyright Copyright (c) 2017 www.tigren.com
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Tigren_Wishlist',
    __DIR__
);

After completing the above steps, please run the following commands:
php bin/magento setup:upgrade
php bin/magento cache:flush
Finally, reload the page.

See More:

[Fix It Series] Front Controller Reached 100 router Match Iterations

[Fix It Series] Custom Option Type Fields Are Not Displayed

How To Config URL Rewrite in Magento 2?

How To Format SEO URL With Slashes in Magento?

5 Undeniable Benefits Of Magento Monthly Support Packages

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Leave a Reply

Your email address will not be published.