Question

this is happing when i do transaction using paytm then success page not removing purchased product from cart is there any solution to solve it

Was it helpful?

Solution

Try the following way using a plugin:

app/code/VendorName/ModuleName/etc/di.xml

<type name="Magento\Checkout\Model\Session">
    <plugin name="sr_checkout_clear_quote_after_order" type="VendorName\ModuleName\Plugin\Model\Session" sortOrder="1"/>
</type>

app/code/VendorName/ModuleName/Plugin/Model/Session.php

namespace VendorName\ModuleName\Plugin\Model;
class Session
{
    /**
     * Destroy/end a session
     * Unset all data associated with object
     * 
     * @param \Magento\Checkout\Model\Session $subject
     * @param $result
     * @return mixed
     */
    public function afterClearQuote(
        \Magento\Checkout\Model\Session $subject,
        $result
    ) {
        $subject->setLoadInactive(false);
        $subject->replaceQuote($subject->getQuote()->setIsActive(false)->save());

        return $result;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top