2

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.

  • How are you creating your page? Are you displaying "Add to cart" button in product listing page? – Jayendra Kainthola Oct 29 '13 at 12:38
1

Using Drupal Rules Module:

To redirect directly to checkout after a user clicks 'add to cart'

  1. Admin -> Configure -> Rules -> Add New Rule
  2. Give it a title of 'Add to Cart - Redirect to Checkout'
  3. Set React on event to: After adding a product to the cart
  4. Add new Action - set this to 'Page redirect'
  5. 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.

  • Hi TreyeDesigns and welcome. Though it might be possible to use these methods to solve the problem, could you include what the user would need to do to achieve the desired functionality? (What hook and which rules would help here?) – Neograph734 Sep 29 '17 at 9:12
  • 2
    I have updated my initial post to be more helpful. – TreyeDesigns Sep 30 '17 at 12:27
0

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.