Skip to main content
added 1 character in body
Source Link
john
  • 302
  • 1
  • 9

I use drupal commerce trying to build a website which sells content (nodes with restricted access). The thing is that, if user have bought the product once, he shouldn't have a possibility to do it again.

Currently i'm using form_commerce_add_to_cart_form_alter to check if user has already added this product to cart and if yes - hide "Add to Cart" button to prevent doing it twice and set a text that this very product is already in the cart. It works totally fine.

What I want to do next are two thingthings:

1) to check if this current user has this product under active (not canceled and not complete) order, and if yes - hide "Add to cart button" and set a text that this product is under order processing at now.

2) to check if this current user has purchased this very product ever before and if he has, do the same trick - hide "Add to cart button" and set a text that User already owns this product.

My problem is that I'm very new to commerce and unfortunately totally don't understand how can aI get all orders for the current user and check for some product IDs there... Will be very appreciated for any advice or a tip. Thanks a lot!

I use drupal commerce trying to build a website which sells content (nodes with restricted access). The thing is that, if user have bought the product once, he shouldn't have a possibility to do it again.

Currently i'm using form_commerce_add_to_cart_form_alter to check if user has already added this product to cart and if yes - hide "Add to Cart" button to prevent doing it twice and set a text that this very product is already in the cart. It works totally fine.

What I want to do next are two thing:

1) to check if this current user has this product under active (not canceled and not complete) order, and if yes - hide "Add to cart button" and set a text that this product is under order processing at now.

2) to check if this current user has purchased this very product ever before and if he has, do the same trick - hide "Add to cart button" and set a text that User already owns this product.

My problem is that I'm very new to commerce and unfortunately totally don't understand how can a get all orders for the current user and check for some product IDs there... Will be very appreciated for any advice or a tip. Thanks a lot!

I use drupal commerce trying to build a website which sells content (nodes with restricted access). The thing is that, if user have bought the product once, he shouldn't have a possibility to do it again.

Currently i'm using form_commerce_add_to_cart_form_alter to check if user has already added this product to cart and if yes - hide "Add to Cart" button to prevent doing it twice and set a text that this very product is already in the cart. It works totally fine.

What I want to do next are two things:

1) to check if this current user has this product under active (not canceled and not complete) order, and if yes - hide "Add to cart button" and set a text that this product is under order processing at now.

2) to check if this current user has purchased this very product ever before and if he has, do the same trick - hide "Add to cart button" and set a text that User already owns this product.

My problem is that I'm very new to commerce and unfortunately totally don't understand how can I get all orders for the current user and check for some product IDs there... Will be very appreciated for any advice or a tip. Thanks a lot!

Source Link
john
  • 302
  • 1
  • 9

Commerce - check if this very product in presented in user's previous orders

I use drupal commerce trying to build a website which sells content (nodes with restricted access). The thing is that, if user have bought the product once, he shouldn't have a possibility to do it again.

Currently i'm using form_commerce_add_to_cart_form_alter to check if user has already added this product to cart and if yes - hide "Add to Cart" button to prevent doing it twice and set a text that this very product is already in the cart. It works totally fine.

What I want to do next are two thing:

1) to check if this current user has this product under active (not canceled and not complete) order, and if yes - hide "Add to cart button" and set a text that this product is under order processing at now.

2) to check if this current user has purchased this very product ever before and if he has, do the same trick - hide "Add to cart button" and set a text that User already owns this product.

My problem is that I'm very new to commerce and unfortunately totally don't understand how can a get all orders for the current user and check for some product IDs there... Will be very appreciated for any advice or a tip. Thanks a lot!