Get Customer Level price with quote(cart) observer

Here we may achieve the quote items and quote table data from an event triggered during the product is added to the cart

checkout_cart_product_add_after


required Repository

use Magento\Catalog\Model\Product\Type\PriceFactory;
use Magento\Customer\Model\Session;


Construct
        PriceFactory $priceModelFactory,
        Session $customerSession

        $this->priceModelFactory = $priceModelFactory;
        $this->customerSession = $customerSession;

 

$item = $observer->getEvent()->getData('quote_item');
        $quoteItem = $observer->getEvent()->getQuoteItem();
        $productinfo = $quoteItem->getProduct();
        $customerGroupId = $this->customerSession->getCustomerGroupId();
        $priceModel = $this->priceModelFactory->create();
        $productPrice = $priceModel->getFinalPrice($customerGroupId, $productinfo);
        $logger->info("final price" . $productPrice);

Leave a comment

Your email address will not be published. Required fields are marked *