0

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.

2 Answers 2

1

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.

  • Takes in $_product as its argument
  • Checks if $_product has any custom options. See below
  • Returns $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..

$options = $product->getOptions();
if ($options) {
    return true; // has custom options
} else {
    return false; // no custom options
}
0

Inside your loop in list.phtml which displays addtocart button,

check if product has $_product()->getoptions() then change the hide your add to cart button and add another button and add redirection url to this button to redirect to product detail page.

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.