Closed (fixed)
Project:
Commerce File
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
26 Jan 2012 at 16:31 UTC
Updated:
26 Jun 2014 at 10:48 UTC
Jump to comment: Most recent
Comments
Comment #1
itamair commentedany feedback on this?
Comment #2
yanniboi commentedYes this would be really helpful! I would like to take one of my existing products once a month and offer it as a free download without having to create a new node with a file field as the product should already be on the website.
Comment #3
alexander_danilenko commentedTry to use rules:
Events: Calculating the sell price of a product.
Conditions: as you need. For example, if user has a role.
Actions: Set the unit price to a specific amount.
Comment #4
itamair commentedMmmhhh … but what might such a Rule accomplish but setting as zero the price of the product?
Should I create a new Rule that based on that would bypass the checkout process and then expose the file for free download.
May be … but still didn't go to much through this solution, yet.
Rather I would now accomplish this integrating and as a variation to the solution I found to expose already bought files to user that bought them, hiding the add to chart bottom contextually. I did it with the solution (personal module) described here: http://drupal.org/node/1266132#comment-5672306
In the case of zero price I might simply alter the form to hide the add to cart bottom and use views to expose the commerce_file for free download, to anybody.
Though quite creative, tt really should work … although I don't know if might be considered the best solution and workaround the this issue.
any further comments would be really welcome!
;-)
Comment #5
cameron prince commentedMy solution to this problem was to create a second file field for the product type. The first file field is the Commerce File type which is stored in the private file system. The second, free file, is the normal file type stored in the public file system. A free download item has a price of zero and the download is stored in the free file field whereas non-free downloads have a price greater than zero and are stored in the commerce file field. The widgets automatically detect the presence of a file in the fields and hide/show themselves appropriately.
The following code takes care of hiding the price and add to cart form:
Comment #6
hmartens commentedI've done this for a client. I wrote a step by step tutorial with screenshots on getting this functionality in Drupal Commerce. To view the full tutorial, head on over to the page on my website
Basically this is what I did:
Go to Store > Configuration > Payment methods
Click on "edit" next to your payment rule, in my case it is "Paypal WPS"
Under "Conditions", add a condition called "Price comparison" . Under "Operator", select '>=' and under "Second Price" type in $0.1 . It didn't want to take $0 so I made it $0.1 because I know I'll never have something that cheap. Save this rule and now it should be active.
Comment #7
bojanz commentedThanks, hmartens!
I would personally always force a checkout, even for free files (since that's where the license is usually created, and it gives you the order as the record of "purchase" too). Commerce No Payment or a similar solution can be used to register a "0 payment" for free orders.
Comment #8
hmartens commentedBojanz, I am actually going through the whole checkout process with my steps and it is creating a license file and keeping it on record that you "purchased" the file. I'm only bypassing the payment method and assigning transaction completed to the "purchase".
But I'll look into Commerce No Payment next time round :) Thanks for your feedback.
Comment #10
chandu7929 commentedhi every one!
since i didn't find any sol. regarding this so i have modified the commerce_file.module file and now it working as i was expecting.
please find the below function
function commerce_file_bypass_license_control($account = NULL) {
return user_access('bypass license control', $account) || user_access('administer licenses', $account);
}
and replace with
function commerce_file_bypass_license_control($account = NULL) {
return user_access('bypass license control', $account) || user_access('administer licenses', $account) || download_free_product_file();
}
now add this additional function in the same file
/**
* it will expose the file for the product whose price is 0 (zero).
*/
function download_free_product_file() {
global $user, $pid;//this is define in
$lp = commerce_product_load($pid);
//$price = entity_metadata_wrapper('commerce_product', $lp)->commerce_price->value();
$price = $lp->commerce_price['und'][0]['amount'];
if($price == 0 && $user->uid) {
return TRUE;
}
}
now add this line in function
commerce_file_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
global $pid;
$pid = $entity->product_id;
keep all the content as it is.
now you are done any autheticated user will be able to see the commerce file link. you dont need to checkout for those product whose price is 0 (zero).