Hello,

This module looks interesting and I am testing it using Drupal 6.19 and Ubercart 6.x-2.4 and Viral descount 6.x-1.x-dev. After install, I can see the module in each of my products but cannot make it work as I am using payment method "PayPal Website Payments Standard" with a paypal sandbox account for testing. In the configuration of "PayPal Website Payments Standard settings" the "Payment action" has two options, "complete sale" or "Authorization" and I selected the last one but Viral discount seems not working. I "enabled" de Virus discount and inserted the discount amount in my product and after pressing Save, the Virus discount configuration remains empty.

Could you clarify how the following comment should be implemented, please?

* Set your payment method to authorization only, uc_viral only works with delayed collection only previously authorized payments

Is there anything else I should do to make it work?

Many thanks

Comments

andrews501’s picture

Hi,

Hope someone could help.

After installing uc_viral I am having this error after trying to create any new node in a new installation of Drupal 6.19, PHP 5.2.12 and MySQL 5.0.41, and jQuery UI 1.6:

Fatal error: Cannot access empty property in .../includes/common.inc on line 3520

Looking at the common.inc file I see that the error originates here:

3503 // Build the SQL.
3504 $query = '';
3505 if (!count($update)) {
3506 $query = "INSERT INTO {". $table ."} (". implode(', ', $fields) .') VALUES ('. implode(', ', $placeholders) .')';
3507 $return = SAVED_NEW;
3508 }
3509 else {
3510 $query = '';
3511 foreach ($fields as $id => $field) {
3512 if ($query) {
3513 $query .= ', ';
3514 }
3515 $query .= $field .' = '. $placeholders[$id];
3516 }
3517
3518 foreach ($update as $key){
3519 $conditions[] = "$key = ". db_type_placeholder($schema['fields'][$key]['type']);
3520 $values[] = $object->$key;
3521 }
3522
3523 $query = "UPDATE {". $table ."} SET $query WHERE ". implode(' AND ', $conditions);
3524 $return = SAVED_UPDATED;
3525 }

Any help will be very much appreciated.

In the meantime I deactivated uc viral, but it would be great be able to use it.

Thanks

mattcasey’s picture

All the issues here seem to be the same. I'm looking for this feature and would like to help if anyone's been working on this.

[Update] on line 85 of the module, it sets up $update as an empty string, but in common.inc, this gets converted to an array that returns a value, so Drupal assumes it is updating a node, when it should be inserting. The fix is to set it as an empty array. I also adjusted the case 'update' because it didn't seem to be saving anything when I edited a pre-existing product. This module should probably take care of a few more cases, for instance if a node gets deleted.. (nodeapi example: http://drupalcontrib.org/api/drupal/contributions--examples--nodeapi_exa...). I"m also not sure of the difference between using drupal_write_record vs. db_query

function uc_viral_nodeapi($node, $op, $teaser, $page) {
  $update = Array();
  switch ($op) {
    case 'update':
      $update = 'nid';
	  db_query('DELETE FROM {uc_viral_products} WHERE nid = %d', $node->nid);
      db_query('INSERT INTO {uc_viral_products} (nid, discount, redirect, enabled) VALUES (%d, %d, %d, %d)', $node->nid, $node->discount, $node->redirect, $node->enabled);
    case 'insert':
      $node->uc_viral['nid'] = $node->nid;
      drupal_write_record('uc_viral_products', $node->uc_viral, $update);
      break;
  }
}