Currently when I click onto a category and see a list of products, it puts a select button next to each product in list mode. Select brings you to the product page.

I would like to replace that select button with an add to cart button that adds the product to the cart from the product list.

Here is my current list.phtml that has select button: https://bpaste.net/show/e4e3e977c8ee

Here is my attempt at making a list.phtml that has an add to cart button rather than a select button. https://bpaste.net/show/5145c07340f4

Here is my view.phtml file for the actual product page where I stole some of the add to cart code from: https://bpaste.net/show/d147bd4b2464

1 Answer 1


I figured it out!

I replaced

<button type="button" title="<?php echo $this->__('Select') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Select') ?></span></span></button>


<button class="button related" type="button" onclick="location.href='<?php echo $this->getAddToCartUrl($_link) ?>'"><span><?php echo $this->__('Add to Cart') ?></span></button>   

And put this at the bottom:

<script type="text/javascript">
    var productAddToCartForm = new VarienForm('product_addtocart_form');
    productAddToCartForm.submit = function(button, url) {
        if (this.validator.validate()) {
            var form = this.form;
            var oldUrl = form.action;

            if (url) {
               form.action = url;
            var e = null;
            try {
            } catch (e) {
            this.form.action = oldUrl;
            if (e) {
                throw e;

            if (button && button != 'undefined') {
                button.disabled = true;

    productAddToCartForm.submitLight = function(button, url){
        if(this.validator) {
            var nv = Validation.methods;
            delete Validation.methods['required-entry'];
            delete Validation.methods['validate-one-required'];
            delete Validation.methods['validate-one-required-by-name'];
            // Remove custom datetime validators
            for (var methodName in Validation.methods) {
                if (methodName.match(/^validate-datetime-.*/i)) {
                    delete Validation.methods[methodName];

            if (this.validator.validate()) {
                if (url) {
                    this.form.action = url;
            Object.extend(Validation.methods, nv);
  • Anyone help me to solve Add-To-Cart Button error, justpaste.it/6olmv
    – Gem
    Commented Aug 18, 2018 at 10:05

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.