1

I am trying to develop a transaction process between two users who can do transaction using a form with two fields:

  • a text message to communicate back and forth
  • a virtual point to trade the product instead of regular currency.

So I customized the checkout process in the Drupal Commerce module. And I tried the Privatemsg module for messages. And Commerce userpoints for the virtual currency. I also customized the "Price" field in Commerce Product field.

I thought I might use Commerce Extra Panes to replace the default checkout steps, but I am stuck because the Privatemsg message text field may not display in the extra pane (I created a content for Privagtemsg to be attached and Extra pane may include the content node with Privatemsg).

This process allows the store owner to use messages and virtual currency to negotiate with the buyer back and forth, so we need a form for them to fill. I also wonder if Rules may provide a form that allows users to enter whatever they want in the checkout process?

I am new in Drupal so I am not sure if this is a good approach. Do you think if this way works? Or any other solution?

  • Try Rules Module drupal.org/project/rules – niksmac Jul 14 '15 at 8:43
  • @NikhilM : use "Rules" for "what"? Which Event(s), which Condition(s), which Action(s))? Better still, post an answer with an EXPORT of the exact rule that would do what you are thinking of, OK? – Pierre.Vriens Jul 14 '15 at 9:34
  • @Pierre.Vriens: Thank you for approaching me and telling me the confusion part. I updated my description. I understand Rules will help me for the point transaction, but I couldn't handle the message part. – pcchen Jul 14 '15 at 9:52
  • @Pierre.Vriens i am thinking like this, use Rules event Order Created and action Send Private Message, and select data using custom PHP :) will that work? – niksmac Jul 14 '15 at 10:05
0

You may want to use the integration between the User Points module and the Rules module to "roll your own cookies", by writing some custom rules to transfer user points from one account to another.

As a sample, have a look at this rule, which is used in combination with voting of a node, whereas the author looses "-2" points, and the voter looses "-1" points:

{ "rules_votedown_question" : {
    "LABEL" : "votedown_question",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "answers" ],
    "REQUIRES" : [ "rules", "voting_rules", "userpoints_rules" ],
    "ON" : { "voting_rules_insert_node" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "answers_question" : "answers_question" } }
        }
      },
      { "voting_rules_condition_check_vote_value" : { "vote" : [ "vote" ], "value" : "-1" } }
    ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "node:author" ],
          "points" : "-2",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Receive downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "QuestionDownvoteReceived",
          "reference" : "By uid=[vote:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      },
      { "userpoints_action_grant_points" : {
          "user" : [ "vote:user" ],
          "points" : "-1",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Issue downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "QuestionDownvoteIssued",
          "reference" : "From uid=[node:author:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      }
    ]
  }
}

If you simply adapt the amount of points (-2 and -1) to something like (eg) +25 and -25, you've a prototype to transfer (25) user points from one user to another.

If you replace the Rules event by an event like "Something is flagged" (created with the Flag module, and the "something" being a product), then a simple click could be used to indicate "I want to transfer 25 user points of mine to this user" (probably to trade that product in your case).

You could take this even a step further: since flags are fieldable, you could add these fields to such flag (to implement a bidding-system):

  • A field to indicate the amount of points to be "moved" (= like the price to be payed for the product?).
  • A field to indicate the price requested by the seller.
  • A field to indicate the price offered by a potential buyer.
  • A field for some text to be used for storing some message text. Possibly you may want to "deliver" that message text using the Message module, which has a great integration with Rules also (though it's not obvious to get started with the Message module).

Note: The above Rules example may need further refinements, e.g. if you want to ensure that after moving points van User A to User B, the remaining points for User A is not negative. Refer to "How to check whether one's current User Points are negative with the Rules module?" for details about how you can implement such refinement also.

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.