Currently the new created recurring products are not available as variables in the Rule: "commerce_recurring_generate_recurring_product"
But that would for example help if the product contains special fields that shell be transfered into the generated recurring product.
Rules provides a simple helper for adding new variables, as described here: https://drupal.org/node/878972
You've also perfectly prepared that in commerce_recurring.rules.inc so that only little additions are required:
Add
'provides' => array(
'new_commerce_recurring' => array(
'type' => 'commerce_recurring',
'label' => t('Generated commerce_recurring entity'),
),
),
in the rules action array:
$actions['commerce_recurring_generate_recurring_product'] = array(
'label' => t('Create / Update a recurring entity from product data'),
And return the new commerce_recurring entity in function commerce_recurring_rules_generate_recurring_product:
return array('new_commerce_recurring' => $recurring_entity);
It works great and makes the module even a bit more flexible.
I can't create a patch in my current dev environment so would you perhaps be so kind to add that functionality, if you like it? :)
Thanks a lot for this great module!
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 2109959-provide-rules-variable-on-creation-of-recurring-products-3.patch | 962 bytes | jpstrikesback |
Comments
Comment #1
anybodyAs I've seen you already use this technique in other places, so it would be very cool to have it here also.
Comment #2
pcambraWould you be willing to provide a patch with this?
Comment #3
jpstrikesback commentedThanks @Anybody! Here is that patch.
Comment #4
jpstrikesback commentedComment #5
thirdender commentedI accidentally re-created a nearly identical patch :-p I went to create an issue and found this.
Let's get this committed. My approach and patch were nearly identical, the only difference was the variable name I chose for the provided variable. I ended up modifying my code to use this patch instead. I think we can mark this RTBC.
I'm using this patch to store a reference to the original
commerce_line_itemon the newly createdcommerce_recurringentity. I need the original line item to access Commerce Product Option options chosen by the customer during the initial purchase. If I get everything working as I intend, I plan to file an additional issue with that code as well.Comment #6
joelstein commented+1. This patch works great and adds intuitive missing functionality. I expected the "Create / Update a recurring entity from product data" action would provide a reference to the newly created Recurring Entity, and with this patch, it does.
Comment #7
nrogers commented+1. I too expected this as the default behavior. Looks/works great for me.
Comment #8
deggertsen commented+1. This looks great. Very helpful. I have requested to become a new maintainer so if that happens I will try to get this committed.
Comment #10
deggertsen commentedCommitted. Thanks everyone.