You are here

function uc_recurring_product_feature_save in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 modules/uc_recurring_product/uc_recurring_product.module \uc_recurring_product_feature_save()
2 calls to uc_recurring_product_feature_save()
uc_recurring_product_feature_form_submit in modules/uc_recurring_product/uc_recurring_product.module
Submit handler for the recurring feature.
uc_recurring_subscription_product_form_submit in modules/uc_recurring_subscription/uc_recurring_subscription.admin.inc

File

modules/uc_recurring_product/uc_recurring_product.module, line 196
Add recurring payments/fees to a product. This is imlpemented through Ubercarts product features.

Code

function uc_recurring_product_feature_save(&$product) {
  $args = array(
    '@product' => empty($product->model) ? t('this product') : t('@model of this product', array(
      '@model' => $product->model,
    )),
    '@amount' => empty($product->fee_amount) ? t('the same amount as the product selling price') : theme('uc_price', array(
      'price' => $product->fee_amount,
    )),
    '@initial' => $product->initial_charge,
    '@regular' => $product->regular_interval,
    '@intervals' => t('@num times', array(
      '@num' => $product->number_intervals < 0 ? t('unlimited') : $product->number_intervals - 1,
    )),
  );

  // Build the feature's data array.
  $data = array(
    'pfid' => $product->pfid,
    'nid' => $product->nid,
    'fid' => 'recurring',
    'description' => t('When @product is purchased, add a fee for @amount charged first after @initial and every @regular after that @intervals.', $args),
  );

  // Save the product feature and store the returned URL as our redirect.
  $redirect = uc_product_feature_save($data);
  if (empty($product->pfid)) {
    $product->pfid = $data['pfid'];
  }
  uc_recurring_product_fee_product_save($product);
  return $redirect;
}