0

Goal:

I want to hide the panel pane containing a view (containing a product display) when the user has purchased the product.

Set-up:

I have a commerce product entity (not display) which is flagged using Rules on behalf of the user who purchases the product. I've created a view to verify the rule and it works, linking the Prod ID to the User ID correctly.

I then have a view:

  • View type: 'Content Pane'

  • Filtered on: 'Content type: Product Display'

  • With a field 'Content: Product Reference' with 'Add to Cart line item type : Commerce node checkout'

The view is displayed in a panel pane and appears as a standard 'add to cart' button. This is also ok and users are able to purchase the product, (which then provides a link to some premium content).

The problem:

In panels, I have a visibility rule on the pane containing the 'add to cart' button. The visibility rule looks for the flag attached to the product and shows it only if the flag is NOT there.

However, the product is always visible.

I've also tried the same procedure, but flagging the 'product display' instead, but with the same result.

I think it's probably that I'm not using the right context or relationship, either in views, panels or both. I've tried a few, but am now at the stumbling in the dark stage. I'm pretty stumped as I thought panels visibility rules would only offer options that were available/in scope. Any help/guidance much appreciated!


EDIT after comment #1 below:

I've added some screen grabs of the panels settings and output.

1 Panels content screen. Top-right panel shows two ways I tried to put the "add to cart" button in. The views method works, the direct panels method does not.

2 Relationships in Panels. I thought this would make the correct entities available to visibility rules, etc. but apparently not.

3 Panels output. The main content (overriden node type) is at the bottom. The "add to cart" button is on the right, and should only appear before purchase, but is always there. The contact details (left) should, and does, only appear after purchase.

4 Very brief diagram of entity relationships.

Panels content screen. Top-right panel shows two ways I tried to put the "add to cart" button in. The views method works, the direct panels method does not

Relationships in Panels. I thought this would make the correct entities available to visibility rules, etc. but apparently not

Panels output. The main content (overriden node type) is at the bottom. The "add to cart" button is on the right, and should only appear before purchase, but is always there. The contact details (left) should, and does, only appear after purchase

Very brief diagram of entity relationships

Further to the orginal description, the following might be useful:

  • Content access module with per-node access control is used to control access to "Contact details" content.
  • There is an option in visibility rules that can base visibility on access of current user to a particular bit of content, which I have tried, and seemed to target the correct content, but didn't work (so obviously wasn't).
  • This suggests to me that it's a matter of getting the correct vars in scope using panel contexts.
  • 1
    Why do you need a view if you only want to render a add to cart button? Maybe you could post a screenshot of your panel setup and the final output? Is it a custom page or node override etc your panel is? – Pontus Nilsson Aug 15 '14 at 7:46
  • Thanks for your reply @pontus. I've added some screen grabs and extra thoughts, which hopefully help. I'm using a view because it was the only way I found to make the "add to cart" & "contact details" elements appear correctly. – Pog Le Pog Aug 15 '14 at 21:47
0

I solved this by using the flag module and rules.

In summary: When the customer buys access to the hidden content, a rule is triggered that flags the content author on behalf of the customer. Panels can set visibility of a pane based on whether this flag exists between author and current user viewing the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.