I want to change the behavior of the Add to Cart button from the list / grid views. Where this is clicked for a product that has custom options that are required, the customer is taken into the product page to complete the options, and then they add to cart.
I want the same behavior for a product that has custom options that are not required. The add to cart button add the product into the shopping cart.
So my question is, how can I change Add to Cart button in list/grid views so that you are moved into the product page whether the optional are required or not.
I realize that making one or more of the options mandatory would solve this, but the options all need to be non-mandatory for reasons.
Best Answer
In
.../template/catalog/product/list.phtml
, you'll see$this->getAddToCartUrl($_product)
. This generates the URL to add to cart. You can create a custom function that places the product URL instead in your case. Check it out.$_product
as its argument$_product
has any custom options. See below$this->getAddToCartUrl(...)
if no custom options. Returns$this->getProductUrl(...)
if at least one custom option is present.To check if a product has any custom attributes at all..