-1

How would I hide the "Add to Cart" button if the product line item already exists in [user] orders?

The situation is an online course, where the a user will buy access to a node. But once they have brought it, they still need to go back to the node to view the content. But we do not want to show the "Add to Cart" button as they have already brought it.

There is a very similar question here: Hide price and add to cart form for purchased product But this only hides the Cart button for 1 SKU. How would this be modified to look at all SKUs in [user]'s orders and hide "add to Cart"?

1

1 Answer 1

0

So I found this code here: http://agileadam.com/2012/04/drupal-commerce-add-to-cart-form-tweaks-registration-improvements/

Change $product->type to your product type

I also changed $form['submit']['#disabled'] = TRUE;
to
$form['submit']['#attributes']['disabled'] = 'disabled';

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.