3

With the Drupal commerce module, I created a new product type I use for selling points to my customers. The product has a custom field named “points” (field type integer) where I specify the amount of point to sell.

On checkout I want to grant the points to the user (with the Userpoint module). I want to do this with rules.

The problem is that I can’t retrieve the field “points” in action rules. I tried adding the “entity has field” condition, but I am not able to retrieve the field from the commerce order.

The action is grants points to a user.

Config screenshot

How can I achieve this?

  • Define "non able to retrieve the field". Show us the code you wrote for your custom action, or screenshot from config screen if it's a built-in action. – Mołot Sep 18 '13 at 7:50
  • Molot is right, Please give us as much information as possible in order to help you and answer your question. – Vic Sep 18 '13 at 7:58
  • Action: grant points to a user. User (The user that will receive the points) commerce-order:owner. But I cant retrieve Points (Amount of points to give or take) that i want to be the value of "points" field. – Derio Sep 18 '13 at 8:28
2

To answer your question in order to give you a solution. That people can "top" up here is maybe an alternative.

Drupal Userpoint Feature request

Remember to use dev version.

Commerce Userpoints

What about something like this ?

  • 1) Rule

Event: on payment completed Action: loop through the order line-items. Each line-item has an action to call the next component with parameters of order and the line-item.

  • 2) Component

Parameters: order, line-item Condition: data comparison line-item:type is Product (to expose line-item:commerce-product) Action: call next component with parameters of order and line-item:commerce-product

  • 3) Component

Parameters: order, product Condition: data comparison product:type is Product (to expose the product:field-points-to-add)

  • Action: add userpoints, number to add being product:field-points-to-add
  • This module allows to buy discount with points, not to buy points for money. Or am I missing something? Please elaborate. – Mołot Sep 18 '13 at 8:11
  • 1
    Thanks for the suggestion. I expose line-item:commerce-product and product:field-points-to-add with entity is of type end entity has field. The rule works! but only if the quantity is one; if I buy more quantity the points granted is always the same. – Derio Sep 18 '13 at 10:23

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.