function commerce_recurring_rules_iterate_recurring_from_order in Commerce Recurring Framework 7.2
Extend recurring entity values after successful recursion.
1 string reference to 'commerce_recurring_rules_iterate_recurring_from_order'
File
- ./
commerce_recurring.rules.inc, line 551 - Rules integration for recurring entities.
Code
function commerce_recurring_rules_iterate_recurring_from_order($order) {
$recurring_entities = commerce_recurring_load_by_order($order);
foreach ($recurring_entities as $recurring_entity) {
$recurring_wrapper = entity_metadata_wrapper('commerce_recurring', $recurring_entity);
$product_wrapper = $recurring_wrapper->commerce_recurring_ref_product;
$product = $product_wrapper
->value();
// Add the order and update all the recurring values needed for the next
// iteration.
// Due date: previous due date + recurring period.
// End date update.
if (!empty($product->commerce_recurring_rec_period)) {
$recurring_interval = $product_wrapper->commerce_recurring_rec_period
->value();
if (!empty($recurring_interval)) {
$date = new DateObject($recurring_entity->due_date);
interval_apply_interval($date, $recurring_interval, TRUE);
$recurring_entity->due_date = $date
->getTimestamp();
entity_save('commerce_recurring', $recurring_wrapper
->value());
}
}
}
}