I think this can be done by creating a view block with an argument from the URL. But if a user can easily attach a block with "Purchase subscription to this group" button to the group of concern, that will increase the usability a lot, I think.

Comments

aiwata55’s picture

Maybe impossible even by manipulating Views?

I am not a Views expert, so I may be wrong, but I couldn't figure out how to show a "Buy subscription now" button in a block for the current group when a user doesn't have a membership for the current group. Maybe Ubercart Organic Group Subscrive module needs to provide argument(s) in order to interact with Views?

If there is a proper way to achieve this, please kindly let me know.

aiwata55’s picture

I think I found a maneuver. Just in case there are those who face the same needs, I would like to share my solution.

  1. In the SKU field of the product nodes, enter the node ID of the group for which subscription is sold.
  2. Create a view, configure the view as you wish, such as fields to include, filters, and sort criteria.
  3. Add an "Product: SKU" argument.
  4. Select "Provide default argument" under "Action to take if argument is note present:"
  5. Select "PHP Code" under "Default argument type:"
  6. Enter the following PHP code.
    global $account;
    $node = node_load(arg(1));
    if (!og_is_group_member($node, FALSE, $account->uid)) {
        return $node->nid;
    }
    
  7. Create a block display.
  8. Place the view block.

The PHP code checks if the user has already subscribed to the current group, and if not then passes the node ID as an argument. Views filters nodes whose SKU field matches the argument (which is the node ID). Therefore only the corresponding subscription product will be presented in the block.

Hope this is useful.