how to redirect to shopping cart page by clicking proceed to checkout button in magento2 . And which file need to add in our custom module

1 Answer 1


To redirect to the shopping cart by clicking on 'proceed-to-checkout button' in the minicart you can edit 'Magento/Checkout/Block/Cart/Sidebar.php' function 'getConfig' and edit 'checkoutUrl'

Here is the way to do it in your custom module

1. In your di.xml

Add a plugin

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type name="Magento\Checkout\Block\Cart\Sidebar">
        <plugin name="UpdateMinicartCheckoutLInk"

2. Create the plugin file

In the folder Plugin create UpdateMinicartCheckoutLink.php


namespace Vendor\Magento\Plugin;

use Magento\Checkout\Block\Cart\Sidebar;

class UpdateMinicartCheckoutLink
     * @param Sidebar $subject
     * @param array $result
     * @return array
    public function afterGetConfig(Sidebar $subject, array $result): array
        $result['checkoutUrl'] = $subject->getShoppingCartUrl();
        return $result;

3. Flush magento cache

bin/magento c:f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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