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!

Comments

anybody’s picture

As I've seen you already use this technique in other places, so it would be very cool to have it here also.

pcambra’s picture

Issue summary: View changes

Would you be willing to provide a patch with this?

jpstrikesback’s picture

Thanks @Anybody! Here is that patch.

jpstrikesback’s picture

Status: Active » Needs review
thirdender’s picture

Status: Needs review » Reviewed & tested by the community

I 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_item on the newly created commerce_recurring entity. 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.

joelstein’s picture

+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.

nrogers’s picture

+1. I too expected this as the default behavior. Looks/works great for me.

deggertsen’s picture

+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.

deggertsen’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks everyone.

Status: Fixed » Closed (fixed)

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