Closed (duplicate)
Project:
Commerce File
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Aug 2013 at 01:50 UTC
Updated:
18 Aug 2013 at 23:07 UTC
Jump to comment: Most recent
Comments
Comment #1
bojanz commentedHi, I'm tracking this in #2049629: Prevent the user from buying a file license twice.
My plan is to hide the add to cart form and show the download links instead.
You'll be able to copy the approach and supply something else if needed.
Comment #2
surfkid commentedThat would be perfect. I saw that post also. I will watch both posts.
Thank you again!
Comment #3
bojanz commentedYou can use something like this as a first measure:
I need to brainstorm on more complete code (multiple referenced products, anonymous checkout).
Comment #4
surfkid commentedThank you!
It works!
I am using multiple products on one product display and it does switch along with the price options.
I have the "file" link displayed under the add to cart form, so it already only shows if you have a license (download link or plain text) and hides when you don't have a license, so you may not need to have it switch to have a link. That is already possible now.
I tried this link,
http://agileadam.com/add-to-cart-tweaks
which also works checking the items in the cart. But I was trying to use the "commerce_file_get_product_license" as I think it's a better implementation. This link did not work for multiple referenced products as it checked for "product" and not license.
I like the "get_license" route also because if for some reason a customer wants to repurchase, you can just delete their order (and license) and the "add to cart" is back for repurchase. Maybe in other instances, other users may want the add to cart to appear back when limits are reached or something. Maybe make that configurable somehow.
The already in cart thing is cool though. It may be worth a look.
I tweaked the code a little to display "Already Purchased" on the button.
Thank you so much!!
Comment #5
brodiebrodie commentedHi there,
could you tell me how you t tweaked the code a little to display "Already Purchased" on the button.?
Thanks for this
Brodie
Comment #6
brodiebrodie commentedGot it! kind of
$form['submit']['#disabled'] = TRUE;
$form['submit']['#value'] = t('Purchased');