How to redirect customers to the checkout page after login when the cart is not empty for the customer?
Loginpost\Redirect\etc\frontend\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="\Magento\Customer\Controller\Account\LoginPost">
<plugin name="loginpost_redirect_loginpostplugin" type="\LoginPost\Redirect\Plugin\LoginPostPlugin" sortOrder="1" />
</type>
</config>
Loginpost\Redirect\Plugin\LoginPostPlugin.php
<?php
namespace Loginpost\Redirect\Plugin;
class LoginPostPlugin
{
public function afterExecute(
\Magento\Customer\Controller\Account\LoginPost $subject,
$result)
{
$result->setPath('/checkout');
return $result;
}
}
Now I'm getting following error after adding this plugin to my project.

app/code/[vendor_name]/[module_name]. You can choose the Vendor and Module name as per your requirements. For example,/Sumit/CustomerLogin/Plugin/LoginPostPlugin.php– Sumit Aug 12 '19 at 09:22bin/magento setup:upgradeto add this plugin to the project. it's run without error but i get a error1 exception(s): Exception #0 (InvalidArgumentException): Plugin class LoginPost\Redirect\Plugin\LoginPostPlugin doesn't exist, plugin file content and module.xml added in the question above. can you figure out what is went wrong with this. – ashanr Aug 13 '19 at 09:33