Magento 2 – Changing Minicart Header

cartmagento2mini-cart

I have button in mini cart header with title – "go to checkout". This button currently links to checkout, (which is correct), however I need to change this link to cart page (not the checkout).

<button
    id="top-cart-btn-checkout"
    type="button"
    class="action primary checkout"
    data-bind="attr: {title: $t('Go to Checkout')}">
    <!-- ko i18n: 'Go to Checkout' --><!-- /ko -->
</button>

File location is:

Vender/theme/Magento_Checkout/web/template/minicart/content.html

Its obviously built and controlled through knockoutjs – so I had a look inside of:

Vender/theme/Magento_Checkout/web/js/view/minicart.js

Seems as though there is a function inside of there called, initSidebar this calls the miniCart.sidebar however I can't see where it is generating the url for the button to link through to the checkout.

Any help?

Best Answer

Make it link, instead of a button:

<a class="action viewcart" data-bind="attr: {title: $t('Checkout'), href: shoppingCartUrl}">
    <span><!-- ko i18n: 'Checkout' --><!-- /ko --></span>
</a>

You might need to adjust the styling after making this change.

Related Topic