Add to cart button: link rather than button?


My cart page is a form with the products, followed by buttons continue shopping, update cart, checkout...

The design calls for me to put upsell "add to cart" buttons between the lower buttons and the upper cart contents.

I can create a view which fetches the "promoted" items, and generate "Add to cart" forms within the views, then use hook_form_alter() to add markup embedding the view within the existing form.

This, however, violates HTML's restriction on form elements being embedded (plus it does not work if the "parent" form has required elements).

I can't think of an elegant way to deal with this, except having a "buy now" link (not a button).

I'm wondering if anyone has has any ideas.



Posted: Nov 1, 2013


Joel Wallis Jucá on November 1, 2013

Do you really need an anchor element to do that? Think about.

The "Add to cart" button is part of a HTML form which, when submitted, makes an action. And it stands for sending POST data through HTTP. I think you can bypass this issue by styling the button the way you need it looks like.

Remember, you can style ANY HTML element. Just add some CSS, like .my-cool-botton { border: none; background: none; color: #369; } and "you have a link instead of a button."