0
  1. How many price types available in Magento 2.x.x

  2. How it can be loaded on the checkout page?

  3. What is the difference between group price and tier price in Magento 2

1

There are total of 6 types of prices available in Magento2 listed as below:


  1. Special Price
  2. Tier Price
  3. Grouped Price
  4. The minimum price of composite
  5. products Price range of composite products
  6. Manufacturer price (MSRP)

Magento represents these prices as price types (e.g. final price, minimum price, maximum price, regular price) and is separate from the actual price in the code. For example, Special Price is represented by the final price type in the code.

If you want this price values on checkout page then you need to write foreach loop code for each item added into the cart and then you can get its various kind prices for each individual item as below:

Get Simple Price values:

$finalPrice   = $item->getProduct()->getFinalPrice();
$regularPrice = $item->getProduct()->getPrice();
$specialPrice = $item->getProduct()->getSpecialPrice();

Get Group/Tier Price values:

First create block file to define getTierPrice() function:

namespace Namespace\TierPrice\Block;

use Magento\Catalog\Api\Data\ProductTierPriceInterface;
use Magento\Catalog\Api\ScopedProductTierPriceManagementInterface;

class TierPrice extends \Magento\Framework\View\Element\Template
{
    /**
     * @var ScopedProductTierPriceManagementInterface
     */
    private $tierPrice;

    public function __construct(
        ScopedProductTierPriceManagementInterface $tierPrice
    ) {
        $this->tierPrice = $tierPrice;
    }

    /**
     * Get Tier price by the customer group
     *
     * @return ProductTierPriceInterface[]
     */
    public function getTierPrice($sku, $customerGroupId=1)
    {
        return $this->tierPrice->getList($sku, $customerGroupId);
    }
}

Then you can get tier price value in its associated phtml file by calling block function as below:

$tierPrices = $block->getTierPrice($sku, $customerGroupId);

There is a very thin difference between the group prices and tier prices. Customer group prices are a component of tier pricing and are set up in a similar way. The only difference is that customer group prices have a quantity of 1.

I hope this helps you to understand the fundamentals of magento2 price types.

If you have any further query feel free to ask.

Happy to help!

Thanks.

1
  • 1
    Nice explaination by @pratik Navapara Keep it Good work!! Apr 30 '20 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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