I am working with E-Commerce module of Drupal 7. I want to redirect Add to Cart button link to product page only those products which have attribute otherwise I want to add product direct to cart.
Using Drupal Rules Module:
To redirect directly to checkout after a user clicks 'add to cart'
- Admin -> Configure -> Rules -> Add New Rule
- Give it a title of 'Add to Cart - Redirect to Checkout'
- Set React on event to: After adding a product to the cart
- Add new Action - set this to 'Page redirect'
- Give it a value of 'checkout' and save.
Now when users click your add to cart button, they will be taken directly to checkout. Alternatively, you can send them to /cart by change the value in step 5.
You need to add view php options in your listing page and then you can get your attributes in that php field, you put the conditions and make the link as you want
Add a hook form alter that changes the add to cart form to add another #submit callback. In this callback, add your logic to check attributes, if you need to redirect, set $form_state['redirect']
See https://drupal.stackexchange.com/a/128001/42761 for more on how to alter the form