This question was originally posted in the drupalcommerce.org site, but have had no responses, so hopefully this is an appropriate forum: (original post: http://www.drupalcommerce.org/comment/6634#comment-6634)
Background / Setup:
I am attempting to use rules to modify the price of a product based on the value of a field in a referenced entity. I cannot get the field to show up in the rules conditions.
I'm using Drupal 7, commerce, registration, and commerce_registration.
I have a Content type "Event" that has a Product reference field "Register".
My Product reference field references a product type "Event Registration".
My "Event Registration" Product type has a Registration field "Event registration".
To collect registrant data, I have put fields on my Registration type, and these fields show up when proceeding to "Checkout", allowing users to provide their registration information.
These fields also show up on the Commerce review pane, allowing customers to review their registration information (very nice).
I run into trouble with the client requirement "Allow for different price points for types of tickets". E.g. General tickets cost $15, Student tickets cost $10, etc... I cannot seem to figure out how to get the fields into scope so I can use rules' conditions and actions to modify the price.
It *seems* like I need to implement hook_entity_property_info_alter() to tell rules "Hey! I've got these fields, and here's where they are in the database.". I created a mini-module that will dpm() the properties provided by hook_entity_property_info_alter(), but I'm not really sure where to go next. Am I able to update the entity metadata here so that rules will know about it? Ugh.
I've read:
http://drupal.org/node/1053850 (which has more subscribers than our local newspaper!)
http://www.trellon.com/content/blog/creating-own-entities-entity-api (um...just out of my reach without a bit of help)
http://drupal.org/node/1081800#comment-4240420 and followed the steps (#13 - I've tried to follow along, but I simply can't get the referenced fields into scope)
Comments
Comment #1
jameswoods CreditAttribution: jameswoods commentedI ended up patching the registration module to add hook_registration_event_count_alter() and then wrote a small module that counts up all the registrations so I can have my price points AND limited seating.
Comment #2
TravisJohnston CreditAttribution: TravisJohnston commentedHello James,
I stumbled on your post while looking for a way to bring a Product Display into scope in a Rule after checkout completes. After reading your question, even though this is months later, did you happen to look at https://drupal.org/project/commerce_pricing_attributes?
Comment #3
jameswoods CreditAttribution: jameswoods commentedI did...and I don't remember the particulars. I do know that the registration, commerce_registration, and commerce_pricing_attributes modules didn't work together in a way that suited my needs. Sorry I don't have details for ya 8^(
Comment #4
blacklabel_tom CreditAttribution: blacklabel_tom commentedHi,
This is a very old issue, but I would suggest you have different products at different prices rather than changing the price on checkout.
Additionally getting fields into scope in Rules isn't something this module can fix as you will need to check the entity is of type bundle or that the specific field exists in Rules before you can use it.
Cheers
Tom