1

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?

  • Current have you used any custom theme or magento default theme? – Dhiren Vasoya Jan 26 '17 at 10:49
  • Custom build theme. I know its inside of Magento_Checkout/web/js/view/minicart.js that i need to change, but im not sure what. – andy jones Jan 26 '17 at 10:51
  • No, it not there. – Dhiren Vasoya Jan 26 '17 at 10:56
  • Where is the location? – andy jones Jan 26 '17 at 11:00
  • check I post an answer. – Dhiren Vasoya Jan 26 '17 at 11:04
3

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.

  • Cheers man. I don't think the other answer really got where i was going with it. ^_^ – andy jones Apr 25 '17 at 10:51
0

In your custom theme, First you need to overide content.html file like

vendor\magento\module-checkout\view\frontend\web\template\minicart\content.html

to

app\design\frontend\[Your Theme]\Magento_Checkout\web\template\minicart\content.html

replace above code which on arround line no 50.

<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>

with

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

Now it will show View Cart link there.

  • Yes, i know this. I don't want to change the button from a button to a different element, i want to alter the button url location, i don't want to change the button element at all, if anything i only want to alter the js. – andy jones Jan 26 '17 at 11:06
  • I update answer. Please check now. – Dhiren Vasoya Jan 26 '17 at 11:09
  • That doesn't work, you can't pass through a href onto a button & I know the button url is set inside of the js. Doing it like this just results in the button not doing anything. – andy jones Jan 26 '17 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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