On the cart page ("/checkout/cart"), the link to "proceed to checkout" is a with an onclick = window.location that sets the next page. Why is this?

More specifically, is there any risk introduced if I change this to an anchor tag with href = to the getCheckouturl?

This is probably common knowledge, but I could not find insight anywhere else.


  • Do you have enough information to accept an answer yet - perhaps you have discovered something you'd like to add as a self-answer? Either way, please edit your question with additional details or accept an answer so that we can close this out. Thanks. – philwinkle Mar 21 '14 at 13:25

There may be a canonical answer, but my best guess is for the following reasons:

  • Semantics. The button is displayed as a clickable button, therefore the logical HTML element to use is a button.

  • Button 'disabling' becomes possible. By using a button type when the button is disabled (disabled="disabled" attribute), the onclick will not fire. This makes it possible to prevent checkout if some condition has not been satisfied. See an example fiddle here.

  • Javascript is required by Magento in order for the site to function - disable Javascript and you will see a warning from a noscript tag. Providing a button which will only redirect if JS enabled effectively prevents customers from entering the checkout without the ability to proceed.

Is there any risk in using an anchor tag? Not at all. Make sure that you generate the href, however, with the getCheckoutUrl method.

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.