0

I am using ubercart and uc_recurring module and Drupal6. I wanted to add monthly payments to all products by default. How can i do this ?

I added a rule to add the data to the DB using php code while creating new product

$data = array(
  'pfid' => ' ',
  'nid' => $node->nid,
  'fid' => 'recurring',
  'description'=>'When this product is purchased, add a fee for the same amount as the product selling price charged first after 0 days and every 1 months after that 99 times.',
);
drupal_write_record('uc_product_features', $data);

$q = "SELECT pfid FROM {uc_product_features} WHERE fid= '%s' AND nid = %d";
$result = db_query($q, 'recurring', $node->nid);
$num = db_result($result);


$data2 = array(
  'pfid' => $num,
  'model' => ' pro',
  'fee_amount' => ' ',
  'initial_charge'=>'0 days',
 'regular_interval'=>'1 months',
  'number_intervals'=>100,
);
drupal_write_record('uc_recurring_product', $data2);

Still recurring is not working? When i go to the path /node/*/edit/features and simply submit the form without updating any fields it works?

Am I missing anything?

1 Answer 1

0

Finally its solved by changing the code in rules

<?php
    //Recurring
    $data = array(
   'pfid' => ' ',
   'nid' => $node->nid,
   'fid' => 'recurring',
   'description'=>'When this product is purchased, add a fee for the same amount as the product selling price charged first after 0 days and every 1 months after that 99 times.',
     );
   drupal_write_record('uc_product_features', $data);

   $q = "SELECT pfid FROM {uc_product_features} WHERE fid= '%s' AND nid = %d";
   $result = db_query($q, 'recurring', $node->nid);
   $num = db_result($result);


  // Build the recurring fee's product object.
   $product->pfid = $num; //pfid
   $product->model = '';
   $product->fee_amount = 0.000;
   $product->initial_charge = '0 days';
   $product->regular_interval = '1 months';
   // If number intervals is negative, it means that it's unlimited intervals.
   $product->number_intervals = 100;
   $product->nid = $node->nid;

   uc_recurring_product_feature_save($product);
 ?>

I am not sure whether its a proper way..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.