I am running UberCart Marketplace module. I would to implement some form of "Ask the Seller a Question" Form. I considered just creating a webform but I felt privatemsg module might be better. I am looking for functionality similar to Ebay's.

Basically, on each node that the seller (author) creates there should be a link for contacting the seller, additionally, the private message should automically reference which node the link was clicked from. A user should not be able to mistakenly reference a node (product) from another seller.

Additionally, I'd like to have the functionality where the seller can choose whether to publish the question/response to the relevant node. An example would be a user asking a important or frequently asked question. The seller should be able to strip out personally identifying information (user name etc.) and just print the text and response to the relevant node.

Is this currently supported in the 6.1 or 6.2 dev version?

Comments

berdir’s picture

Status: Active » Fixed

Well, it's supported in a way that you can implement that functionality with existing hooks.

In Privatemsg 7.x, private messages are fieldable entities, which means that you could add a node access reference field through the UI.

In 6.x, you can attach custom information with the existing hook_privatemsg_message_*() hooks. See http://api.worldempire.ch/api/privatemsg/privatemsg.api.php/group/messag....

So, you need to do the following steps for the attaching.

1. Create a link on your product display page to which you attach the nid of that product. Something like /messages/new/user_id?product=123. See http://api.worldempire.ch/api/privatemsg/privatemsg.module/function/priv..., $op view for an example of how to use our privatemsg_get_link() api function.

2. Then, implement form_privatemsg_new_alter(), check if a product nid is there and add it as a form field (#type value). Optionally display something so that the user sees what product he is asking about, for example fill the subject in some way.

3. Implement the insert hook, save that value in a custom table that you created (with reference to the mid). Then implement the load hook to load it again when a message is loaded and view_alter() to display the information about that product. See http://api.worldempire.ch/api/search/6-2/privatemsg_attachments_privatem... for examples

The publish stuff is a totally separate thing from that. You can again either add a message action link so they could publish it after they sent th message (similar to delete/block links, see http://api.worldempire.ch/api/privatemsg/pm_block_user--pm_block_user.mo... for example) or again form_alter the reply form and add a checkbox and then act based on that. The publishing itself totally depends on how you want to do it, you could for example do it as a commit of the product node, or display it below the product node information or whatever.

That's all privatemsg specific information I can give you, if you don't know how to do it based on that, ask in the forums, IRC or pay someone to implement it for you. :)

Stomper’s picture

I'll see what I can do, although I have no experience with using hooks. Are there plans to get this functionality into the module via GUI/options list rather than hard coding?

Besides Privatemsg, are there other ways I can do this? Does Webform allow node references?
If I use Webform I'd likely need a node reference and two user references, one node reference to identify the product page, and two user references one for the seller/author and the buyer.

berdir’s picture

No, there is no way that this will become a default/configurable functionality, this is specific for your site and your workflow.

I think there is no way to implement this without having to write any code, even if you use webform you will need to implement a way to display a corresponding link and pre-fill the webform with the corresponding values, that is exactly the same problem as you have with Privatemsg. And the publish part will require custom code too.

nicktr’s picture

A very simplistic way to go about this is just to allow comments on your product items. Users can browse the other comments before they ask a question themselves.
Not exactly what you're looking for, I know, but a half-way method to keep you going until you can implement a more robust solution perhaps?

Stomper’s picture

Thanks for the suggestion, definitely a viable option for the time being. The thing is some questions may be private or the user may not want them publicly displayed.

Is there a way where users can choose whether their comment is publicly viewable or only visible to the node author/seller?

Edit:: Started issue on Comment Permissions module issue queue also http://drupal.org/node/1139018

Ela’s picture

Have you looked into Author Contact module?
It will add a contact form to the nodes, so one can know which page the contact form was sent from.
However.. it will not give you an option to publish the sent contact online.. not that I know of.
Ella

Stomper’s picture

Thanks for the recommendation, Ella. For those interested, I have created an issue on the Author Contact module issue queue here

http://drupal.org/node/1142752

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

d0t15t’s picture

after trying a plethora of different module/message combos, i've decided something like the original post in this thread would suit me best - essentially teasing private messages into something that resembles normal drupal comments. Berdir's suggestion in #1 is, i suppose, the way i'll try this. has anyone had any luck making this work? Any further suggestions?
thx!

d0t15t’s picture

in trying to set up my theme for custom privatemsg fields, i'm having a hard time grabbing the nodes i want.
what works in normal node-field testing doesn't apply to privatemsg fields i assume? any hints would be great - this is what i'm trying

  if ($node->field_alias_reference_msg != NULL)
     {
      print render($content['field_alias_reference_msg']);
      }
gmaximus’s picture

I achieved "Contact the seller links" on product pages using a views block with arguments. I called the block "Seller info" and pulled in stuff from their "content profile". Also used the http://drupal.org/project/prepopulate module, to send the product info to the message. I think using that method kind of simplifies things down to simple configuration. It works a treat :)

Hope that idea helps others...

Guy

damban’s picture

@guyd, if you are still following this thread... any chance you could expand on your method?

gmaximus’s picture

So sorry damban... Only just noticed that you asked this question... Check this out for an alternative approach to privatemsg... That post may take care of your needs better, as it will also allow you to display questions on your product pages...

Here's the code for the view i built. The block it provides, needs to be placed on your product pages. You'll also need priatemsg, content profile (optional, you'll just need to remove those fields from the view) and prepopulate installed.

This technique works by populating the new message to the seller and putting a link to the product in the message body. The seller can then see what product the question is about.

Personally i use privatemsg for "service related" questions and a question content type for the "product questions"...


$view = new view;
$view->name = 'seller_info';
$view->description = 'Seller info block';
$view->tag = '';
$view->base_table = 'node';
$view->core = 6;
$view->api_version = '2';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'content_profile_rel' => array(
    'label' => 'Content Profile',
    'required' => 0,
    'type' => 'profile',
    'id' => 'content_profile_rel',
    'table' => 'users',
    'field' => 'content_profile_rel',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'nid' => array(
    'label' => 'Nid',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'link_to_node' => 0,
    'exclude' => 1,
    'id' => 'nid',
    'table' => 'node',
    'field' => 'nid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'path_1' => array(
    'label' => 'Path relative',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'absolute' => 0,
    'exclude' => 1,
    'id' => 'path_1',
    'table' => 'node',
    'field' => 'path',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'uid' => array(
    'label' => 'Uid',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'link_to_user' => 0,
    'exclude' => 1,
    'id' => 'uid',
    'table' => 'users',
    'field' => 'uid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'name_1' => array(
    'label' => 'Name',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'link_to_user' => 0,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 1,
    'id' => 'name_1',
    'table' => 'users',
    'field' => 'name',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'path' => array(
    'label' => 'Path',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'absolute' => 1,
    'exclude' => 1,
    'id' => 'path',
    'table' => 'node',
    'field' => 'path',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'title' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'link_to_node' => 0,
    'exclude' => 1,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'name' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => '<a href=\'/user/[uid]\'><strong>[name] </strong></a>',
      'make_link' => 0,
      'path' => 'user/[uid]',
      'absolute' => 1,
      'link_class' => 'beautytips',
      'alt' => 'Go to [name_1]\'s user profile, to learn more about them.',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'link_to_user' => 0,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'address' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'hide' => array(
      'locpick' => 'locpick',
      'fax' => 'fax',
      'phone' => 'phone',
      'province_name' => 'province_name',
      'country_name' => 'country_name',
      'map_link' => 'map_link',
      'coords' => 'coords',
      'name' => 0,
      'street' => 0,
      'additional' => 0,
      'city' => 0,
      'province' => 0,
      'postal_code' => 0,
      'country' => 0,
    ),
    'exclude' => 0,
    'id' => 'address',
    'table' => 'location',
    'field' => 'address',
    'relationship' => 'content_profile_rel',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'access' => array(
    'label' => 'Last online',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'date_format' => 'raw time ago',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'access',
    'table' => 'users',
    'field' => 'access',
    'relationship' => 'none',
  ),
  'nothing' => array(
    'label' => '',
    'alter' => array(
      'text' => 'Contact [name_1]',
      'make_link' => 1,
      'path' => 'messages/new/[uid]/Re%3A%20[title]?edit[body]=Product%20page%3A%20[path].&destination=node%2F[nid]',
      'absolute' => 1,
      'link_class' => 'beautytips',
      'alt' => 'Ask [name_1] question.',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'exclude' => 0,
    'id' => 'nothing',
    'table' => 'views',
    'field' => 'nothing',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'title_1' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => 'View profile',
      'make_link' => 0,
      'path' => '',
      'absolute' => 0,
      'link_class' => '',
      'alt' => '',
      'rel' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'hide_alter_empty' => 1,
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title_1',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'content_profile_rel',
  ),
));
$handler->override_option('arguments', array(
  'nid' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'node',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'nid',
    'table' => 'node',
    'field' => 'nid',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      2 => 0,
      5 => 0,
      3 => 0,
      4 => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_taxonomy_tid_term_page' => 0,
    'default_taxonomy_tid_node' => 0,
    'default_taxonomy_tid_limit' => 0,
    'default_taxonomy_tid_vids' => array(
      1 => 0,
      2 => 0,
    ),
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => 'if ( arg(0) == \'node\' && is_numeric(arg(1)) ) {
  $my_id = arg(1);
  echo $my_id ; 
}',
    'validate_argument_node_type' => array(
      'product' => 0,
      'panel' => 0,
      'page' => 0,
      'part' => 0,
      'part_gallery_image' => 0,
      'part_model' => 0,
      'part_question' => 0,
      'profile' => 0,
      'seller_help' => 0,
      'site_admin' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      1 => 0,
      2 => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('title', 'Seller Info');
$handler = $view->new_display('block', 'Product page block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);