How to use Ubercart (UC) Sell CCK Fields Access

Contrib type: 
Other
Status: 
Initial upload
Moderation: 
Awaiting moderation

Downloads


Compatibility: 
Ubercart 2.x

I'd like to add some documentation for an under-documented contrib module but am not sure where.. So here is a first stab Smiling

Installing and using the Ubercart contributed UC Sell CCK Fields Access module is easy with a little guidance.

  1. Download, install, and enable the module under Ubercart Extra - UC Sell CCK Fields Access
  2. Create your cck "product" nodes as usual (Ubercart > Manage Classes)
  3. Append any cck fields to which you wish to sell access (under the usual CCK content Manage Fields)
    Note: Be sure this cck node type is an Ubercart product for the next step..
  4. Protect the fields under Admin > Content > Content field privacy: /admin/content/uc_sell_cck
    This page lists all your Product classes and any CCK fields that can be protected.
  5. Adjust the workflow/Conditional Actions to add Grant CCK field access to customer
  6. ...Not sure what to do from here! At this point, when the order is complete and the user is authenticated, he can now see the CCK when viewing the product..... There's got to be a better way at this point, but this will get you up and running.

Ex. I wanted to sell links, so I protected the CCK Links field on a CCK node using this module.


dom_b's picture
Offline
Joined: 02/26/2010
Juice: 72
Re: How to use Ubercart (UC) Sell CCK Fields Access

I am trying to use this instead of the file downloads feature so I can actually batch import images and sell the high res versions. I'm using views to create a page that lists all the download links that the user has bought access too! looks like it will work well. Just got to work out which database entry holds that information!

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
Re: Re: How to use Ubercart (UC) Sell CCK Fields Access

dom_b: If you're already producing a page of download links to which the user has bought access, then you're probably doing it in a View. In the view, you could easily show the name (and other important info at a glance) and a thumbnail of the image, and then include a link to the original file. This would entail adding the same field twice in the View, and each would be displayed differently (one is an imagecache preset, the other is a link to original file). (If I understand your situation correctly..)

dom_b's picture
Offline
Joined: 02/26/2010
Juice: 72
Re: Re: Re: How to use Ubercart (UC) Sell CCK Fields Access

I've basically achieved the view I want, except I can't get it to show just products that the user has purchased. I need a filter to show all products purchased at any time by the user. I've installed the Ubercart Views module but this doesn't add a filter for all purchased products. Any ideas?

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
module Ubercart Views to show order history / downloads screen

Ok, I didn't catch that from your original email. I too had to create a custom "Downloads" page and came up with a Views page path /cart/your_order (so it stays "within the Ubercart section" of the site). Attached is a screenshot of the view.

Key points:
- you want Ubercart Views to expose uc tables
- check out the filter values:
-- User: Current Yes
-- Ubercart order: Order Status <> In checkout

The special grouping I did is not likely necessary.. I wanted to have the users' entire history of downloads available, lumped by order.

Hope this helps!
-Bronius

AttachmentSize
Ubercart Your Order(s) View 63.13 KB
dom_b's picture
Offline
Joined: 02/26/2010
Juice: 72
Re: module Ubercart Views to show order history / downloads scre

I've tried setting up a similar view but I'm not having any luck with it. I cant seem to filter all the products that the buyer has purchased?

dom_b's picture
Offline
Joined: 02/26/2010
Juice: 72
Re: module Ubercart Views to show order history / downloads scre

Would you be able to export your view so I could import it? Maybe I can troubleshoot from there. Im certain my view is set up correctly. Thanks!

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
Oh. Great idea Ok the only

Oh. Great idea Smiling Ok the only caveat to the attached view export of the view that shows orders after checkout is that it includes SQL Query Aggregator from the views groupby module. Just to make it work without chunking the export code by hand, you might want to install the module temporarily.

AttachmentSize
viewexport-uc-your-order.txt 14.3 KB
Riki's picture
Offline
Joined: 01/10/2009
Juice: 196
Re: How to use Ubercart (UC) Sell CCK Fields Access

Thanks for sharing that. Is there anyway to include which attribute they chose? Ive been trying to modify your view to show that, but its not working. Perhaps this functionality doesnt exist.

- Riki Babington
www.eat3d.com
Feed Your Brain!

swilsondesign's picture
Offline
Joined: 03/01/2010
Juice: 35
Re: How to use Ubercart (UC) Sell CCK Fields Access

Sorry, but I don't quite understand how to get this module working!

It's installed. There have been files uploaded using a CCK file upload field. I have checked this field under the 'content filed privacy' option but the node just shows vanilla Drupal download links.

Am I missing something at point 3?

"Append any CCK fields to which you wish to sell access (under the usual CCK content Manage Fields) Note: Be sure this CCK node type is an Ubercart product for the next step..."

Please can somebody help me out, I've been at this for quite a while now!

Thanks,

Steve

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
Riki- What do you mean "which

Riki-
What do you mean "which attribute they chose?" If a given cck field is protected from viewing using this module/method and is exposed by successful checkout, then the given cck field will be exposed.. Are you wanting to somehow attribute a cck field purchase?
-Bronius

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
Steve- The net result of this

Steve-
The net result of this procedure will be that anyone who has not yet received access to a protected cck field will see the entire node minus that field. Then, after successful checkout, if the customer visits the same node, the protected cck field will then be exposed to them. Is it possible you're just not testing appropriately (ie. as Anonymous in a separate, non-authenticated browser, for example)? Can you give more info about the steps you've followed and the results you're getting?
-Bronius

swilsondesign's picture
Offline
Joined: 03/01/2010
Juice: 35
Hi Bronius, Thanks for the

Hi Bronius,

Thanks for the feedback. Yes, I thought this is how it should work having looked at the site example using it.

Steps I took:

My product classes were already set up: 'music_kit' and 'music_track'
I installed the module
I created a CCK field (type = file, upload) in both 'music_kit' and 'music_track'
I checked the appropriate checkboxes under the CCK Field Access module page ('music_kit' and 'music_track')
I created 'music_kit' and 'music_track' content with files uploaded via the CCK file upload fieldset.
To test, I checked as admin user - the files were displayed in the node. I logged out as anonymous, went to the same node and nothing was there at all. No option to buy, not even a list of attached files.

I know I'm definitely missing the blinding obvious! I would appreciate your help Smiling

Steve

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
Only nodes managed as Ubercart Classes have uc buttons

Are these custom content types classes managed by Ubercart?
Store Admin >> Products >> Manage Classes (/admin/store/products/classes)
If they do not show in this list, then they are not.

I don't know for certain, but I think you could just punch in your custom content type machine names here. I do know that were you to go about it the other way (start with this screen, then go manage fields over at cck) that would work.

swilsondesign's picture
Offline
Joined: 03/01/2010
Juice: 35
Re: Only nodes managed as Ubercart Classes have uc buttons

Yes, they are Ubercart product classes.

What do you mean by 'punch in your custom content type machine names'?

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
Re: Re: Only nodes managed as Ubercart Classes have uc buttons

If they're uc classes, then this is not it.. I was going to suggest that if Ubercart didn't yet know to manage these classes, then you could try typing in the machine name of the cck content types here-- my only uncertainty was whether this would work, or if it would bark at you saying the class names are already taken.

So, interesting that when you view as anonymous, you see nothing at all. Does anonymous have appropriate access set in User >> Permissions to shop? I don't know that these are they, but I have uc_product[View Catalog] and Node[Access Content] set for anonymous on one site I'm looking at..

swilsondesign's picture
Offline
Joined: 03/01/2010
Juice: 35
Hi Bronius, Apologies for not

Hi Bronius,

Apologies for not replying sooner!

Just a quick note to say my issue was resolved. Not quite sure what I did to make the module not work(!) but everything is now okay.

Thanks again,

Steve

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
Re: Hi Bronius, Apologies for not

Glad to hear. Thanks for rounding back just the same Smiling

Pix
Pix's picture
Offline
Joined: 06/01/2010
Juice: 8
placing the hidden cck inside a block with views

hi texas-bronius! Thanks for sharing this super cool module!
i've just tried it and it works beautifully but I'm having some issue with views. I'm trying to place the hidden cck inside a block and it seems like views doesn't respect this module. It shows the cck field even if it's not purchased. I think i'm probably missing a filter or maybe an access rule on the display. Do you have any suggestion?

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
CCK privacy is respected by Views

Pix- First, let me bow away from any credit for having written this worthy module: I only wanted to provide a little documentation to help others.

Next: Views (as in this example) clearly "respects" the privacy settings. Reread the steps above, and try to follow them from start to finish to a T. If you find something that is erroneous, by all means, let's correct them. When you do crack the nut, be sure to double-back with your solution. Anything we can do to make it easier is most welcome!

Pix
Pix's picture
Offline
Joined: 06/01/2010
Juice: 8
Re: CCK privacy is respected by Views

i'll try to summarize my situation here (with less grammar errors as possible...) because with my current setup i'm pretty sure views is ignoring the "protection" on my cck field.
So i have this content type with a cck text field that i want to sell. The first thing i didn't quite get was how to set the cck field permission under admin/user/permission. Should the field that i want to sell start as "available" for authenticated user or not? (i'm allowing purchase only for authenticated users..)
The answer is YES, it should be available under admin/user/permission but it needs to be protected later under admin/content/uc_sell_cck.
Without putting views in the mix everything works fine. I log in with a test account and i cant see the field. After purchasing that node, if i come back i can see it.
Now let say that i want to put that field into a block using views. I can easily create that block having as block-display view with argument the node-id and field my cck field (see attachment). The only filters are on published node( yes) and which content-type...
So at this point i'm thinking that if views is "respecting" the protection, i shouldn't see anything inside my block if i have not purchased the node. I might see an empty block, which is fine, but the result instead is a block with the cck available for any authenticated user...
If i try to add a filter on the Current User (as in your views) the block never shows up. Also i don't know why i should need this filter...
And i'm also sure i don't need a filter checking for the order status here...
So as i was saying before, either i am missing something in my views (another filter?) or the protection is not respected here. Am i wrong?
For now i solved this visibility issue by writing a little php code under the block visibility settings. here it is

<?php
global $user;
$uid = $user->uid;

if (

arg(0!='edit' && is_numeric(arg(1)))) {
   
$node = node_load(arg(1));
   
$nid = $node->nid;
}

if (

$node) {
   
$result = db_fetch_array(db_query("SELECT permission FROM {uc_sell_cck_useraccess} WHERE uid = '%d' AND nid = '%d'", $uid, $nid));

    if (

$result['permission']==1) {
        return
TRUE;
    }else{
        return
FALSE;
    }
}else{
    return
FALSE;
}
?>

I'm checking for the current user and the current node basically, and if there is a match inside uc_sell_cck_useraccess table it means that he had purchased the node.
So please tell me where i'm wrong here (it appens very often)

AttachmentSize
Screen shot 2010-06-03 at 12.54.38 PM.png 103.65 KB
texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
CCK privacy is only aware when joined to the permissions table

Pix-
Ok, I'll backpeddle just a little: Views alone doesn't "respect" cck permissions, but you can't fault it and say it should be aware of permissions without your telling it so.

You're very clever with your workaround, and therein is your solution as well.. Take a look at my view snapshot again and see the relationship against the permissions table that is required: In DB talk, the join will knock out records to which you do not have access and show only those to which you do. Check the info on how to do this in my comment above. The details are to add that relationship and be sure to "show" fields from that relationship, not the primary select. Check my screenshot (on that previous comment) for a better understanding of my rambling..

Good find, Pix!
-Bronius

Pix
Pix's picture
Offline
Joined: 06/01/2010
Juice: 8
Re: CCK privacy is only aware when joined to the permissions tab

I have to say i tried to use that relatioship as in your view, but for some reason my result where different. It's clear now that the relatioship here is the key so maybe i was doing something wrong. I'll try again as soon as possible.
Thank you for your help texas-bronius!

tafa's picture
Offline
Joined: 04/13/2010
Juice: 45
A Little help here more than welcome

Hello all,

I have an issue at hand in relation to the above. Basically, I went through the instructions given in the first post. However, I do not seem to get it right.
First, I created a cck node type using "manage classes".
Second, I defined a couple of existing cck fields as fields in my newly created content type to make sure these fields would be updated in one go.
Third, I went to content privacy fields and ticked one cck field to test it out.
Fourth, I created a new predicate called "Grant CCK field access to customer".
Fifth, I defined the trigger to be "Customer completes checkout" since I want to allow users with a specifc role and membership plan to see this very cck field after purchase.
Sixth, I added a condition "check the user name" to make sure the user was authenticated. In some ways, I am unsure about this.
Seventh, I added an action called " Grant CCK field access to customer". Again, not sure this was what I was meant to be doing.
Eighth, I logged out as admin and logged back in as a normal user.
Result: I am still able to see the CCK field.
Note that I did not add any permission to the field when creating the field through Manage fields in content type. Could this be the problem?

Please let me know. I tried to follow the instructions but I am not good so far and I would love to get it right.

Any comments would be more than welcome.

Thanks
Tafa

dom_b's picture
Offline
Joined: 02/26/2010
Juice: 72
Re: Oh. Great idea Ok the only

Hi thanks for exporting your view! I haven't had a chance to look at it since you exported it so will have a look today and see how it works. Just wanted to say thanks and that I will use it! Appreciate your help.

dom_b's picture
Offline
Joined: 02/26/2010
Juice: 72
Re: CCK privacy is only aware when joined to the permissions tab

I cannot get this relationship to work as you did. I've just completed a purchase of 'product A' as 'user A', I can see the CCK field i have purchased, all great Smiling. I then look at my view which is supposed to show my list purchased products... but nothing in there at all.

If i login as 'admin' and visit my list of purchased products view I can only see the product that 'user A' has just bought?!?! any ideas? it looks like the relationship is against the wrong user or something.

its filtering as current user which i find odd as well...

maybe i should explain what i want to achieve again.

user A logs in, there are 3 products in my store and they buy product A.
The user checks out and the payment is complete.
When the payment is complete they go to myubercartshop.com/purchasedproducts and they see a list of everything they have bought (ie product a) with the cck field next to it.

please help! Smiling

dom_b's picture
Offline
Joined: 02/26/2010
Juice: 72
Re: CCK privacy is only aware when joined to the permissions tab

I finally got this to work by editing out some of the code in your exported view and managing to import it. I cannot for the life of me see what is different to what i created though!

Thanks again.

Smiling

texas-bronius@drupal.org's picture
Offline
Joined: 01/19/2010
Juice: 170
can you export your view and run a diff?

Maybe it would help improve my pseudo-documentation here if you were to now export your view and diff against the one you ended up using. There are others on this thread that need help, but I can't seem to do much more than suggest repeating the steps outlined above: Something must be missing, and in your experience, it appears it might lie buried in the exported view...

colorado's picture
Offline
Joined: 07/31/2010
Juice: 8
Hide price/add to cart on a node for users who have already

I'm trying to hide product details (price)/add to cart on a node for users who have already purchased access to the node.

Any help is much appreciated!

alan_hugo's picture
Offline
Joined: 01/22/2011
Juice: 6
Hi

Hello and tried to follow his footsteps and not succeeded and the sale of cck, and achieved what is to hide cck fields and after the sale the fields remain hidden.
Step 5 apparently do not get it .. I could explain well how to do the "workflow / Conditional Actions to add Grant CCK field access to customer", thanks

alan_hugo's picture
Offline
Joined: 01/22/2011
Juice: 6
Step 5

I'm testing with the condition "check the user´s roles" works perfectly, the problem q all users can view content after a user's role q buy .. Can I tell you put a condition to accessing only the user who bought the cck??, thanks

tamamoshiro's picture
Offline
Joined: 07/19/2011
Juice: 28
Re: How to use Ubercart (UC) Sell CCK Fields Access

Anybody has figure out how to set the views not to show the protected field ?
I followed the instruction above and also with slight tweaks but my views still shows the protected field.
It's perfectly working without views though.