Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sarva/e9fec920790f1ccf34e2 to your computer and use it in GitHub Desktop.
Save sarva/e9fec920790f1ccf34e2 to your computer and use it in GitHub Desktop.
diff --git a/sites/all/modules/contrib/commerce_recurring/commerce_recurring.module b/sites/all/modules/contrib/commerce_recurring/commerce_recurring.module
index b5fb4be..e7e465a 100644
--- a/sites/all/modules/contrib/commerce_recurring/commerce_recurring.module
+++ b/sites/all/modules/contrib/commerce_recurring/commerce_recurring.module
@@ -397,7 +397,7 @@ function commerce_recurring_new(array $values = array()) {
*
* @return entity $recurring_entity
*/
-function commerce_recurring_new_from_product($order, $product, $fixed_price, $quantity) {
+function commerce_recurring_new_from_product($order, $product, $user, $fixed_price, $quantity) {
if (empty($product)) {
return;
}
@@ -428,7 +428,7 @@ function commerce_recurring_new_from_product($order, $product, $fixed_price, $qu
$values = array(
'product_id' => $product->product_id,
'order_ids' => array($order->order_id),
- 'uid' => $order->uid,
+ 'uid' => $user->uid,
'start_date' => $start_date,
'due_date' => $due_date,
'end_date' => isset($end_date) ? $end_date : NULL,
diff --git a/sites/all/modules/contrib/commerce_recurring/commerce_recurring.rules.inc b/sites/all/modules/contrib/commerce_recurring/commerce_recurring.rules.inc
index 5fe21bf..a1882a0 100644
--- a/sites/all/modules/contrib/commerce_recurring/commerce_recurring.rules.inc
+++ b/sites/all/modules/contrib/commerce_recurring/commerce_recurring.rules.inc
@@ -227,6 +227,10 @@ function commerce_recurring_rules_action_info() {
'type' => 'commerce_line_item',
'label' => t('Commerce line item'),
),
+ 'user' => array(
+ 'type' => 'user',
+ 'label' => t('Recurring entity owner')
+ ),
'fixed_price' => array(
'type' => 'commerce_price',
'label' => t('Fixed price for the recurring entity'),
@@ -428,14 +432,14 @@ function commerce_recurring_rules_provide_order_properties($recurring_entity) {
/**
* Generate the recurring entity using the product information.
*/
-function commerce_recurring_rules_generate_recurring_product($order, $line_item, $fixed_price, $quantity) {
+function commerce_recurring_rules_generate_recurring_product($order, $line_item, $user, $fixed_price, $quantity) {
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$product_wrapper = $line_item_wrapper->commerce_product;
$product = $product_wrapper->value();
// We need to check if there's already an order with that recurring entity.
if (empty($order->data['recurring_entity'])) {
- $recurring_entity = commerce_recurring_new_from_product($order, $product, $fixed_price, $quantity);
+ $recurring_entity = commerce_recurring_new_from_product($order, $product, $user, $fixed_price, $quantity);
}
else {
$recurring_entity = entity_load_single('commerce_recurring', $order->data['recurring_entity']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment