I have been attempting to figure this out. When a user purchases a node and the checkout process is complete, the node is published. Now at that point when the user goes to edit the node (which is required in this use case) they are redirected to the cart after submitting the node-edit form. Is there a way the user could just be able to save the node at the point of it being submitted rather then redirected to pay a second time for the node?

Thank you for your assistance in advanced.

Comments

farald’s picture

Maybe its as easy as allowing users to " edit own paynodes " in the permissions settings?

ygg’s picture

Already have tried that, but it appears it does not work that easy.

ygg’s picture

Title: Edit a node without purchasing again » Does no one know on this one?
Priority: Normal » Critical
greggles’s picture

Title: Does no one know on this one? » Don't make the user pay again on subsequent edits of the node
Category: support » bug
Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

This seems like a bug to me.

However, I'm unable to reproduce the behavior that you describe.

glennnz’s picture

Priority: Normal » Critical
Status: Postponed (maintainer needs more info) » Active

This is happening for me too.

Editing a node creates a new node, and adds another product to the cart.

Thanks

Glenn

--UPDATE--

Line 205 of uc_node_checkout.module changes the behaviour of the submit button:

  $form['submit']['#submit'] = array('uc_node_checkout_add_to_cart_submit');

I have tried redefining this in a custom module in a hook_form_alter with:

  $form['submit']['#submit'] = array('my_custom_submit_function');

but this doesn't fix the problem.

Then in uc_node_checkout.module I tried:

  if (!isset($form['nid']['#value'])) {
    $form['submit']['#submit'] = array('uc_node_checkout_add_to_cart_submit');
  }

No luck there either.

--FURTHER UPDATE--

I can't see why this is happening.

Lines 592 - 602 of uc_node_checkout.module are:

    case 'update':
      // Only save attributes if this node has not been checked out.
      if (empty($node->uc_order_product_id) && isset($node->attributes)) {
        $data = db_result(db_query("SELECT data FROM {uc_cart_products} WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", $node->nid));

        $data = unserialize($data);
        $data['attributes'] = $node->attributes;

        db_query("UPDATE {uc_cart_products} SET data = '%s' WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", serialize($data), $node->nid);
      }
      break;

I tried adding:

    case 'update':
      // Only save attributes if this node has not been checked out.
      if (empty($node->uc_order_product_id) && isset($node->attributes)) {
        $data = db_result(db_query("SELECT data FROM {uc_cart_products} WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", $node->nid));

        $data = unserialize($data);
        $data['attributes'] = $node->attributes;

        db_query("UPDATE {uc_cart_products} SET data = '%s' WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", serialize($data), $node->nid);
      }
// Added from here //
      else {
        $data = db_result(db_query("SELECT data FROM {uc_order_products} WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", $node->nid));

        $data = unserialize($data);
        $data['attributes'] = $node->attributes;

        db_query("UPDATE {uc_order_products} SET data = '%s' WHERE data LIKE '%%\"node_checkout_nid\";i:%d;%%'", serialize($data), $node->nid);
      }
// to here //
      break;

with no luck either.

:-(

glennnz’s picture

OK, a workaround.

I didn't want a new node to be created, so I created the function below that is run when the update button on the ode edit page is pushed.

It takes the unedited fields (in my case this was easy, I had most of them restricted anyway) and passes them to the new node, then deletes the old one.

It's very specific to my use-case, but it works....

I tried to use node_delete($nid), but that won't work for some reason.... Maybe to do with the node_load inside node_delete?

Anyway, my code:

function checkin_confirmation_validate($form, &$form_state) {

  // Pass values from old node to new one
  $firstname['#parents'] = array("field_first_name", 0, 'value');
  form_set_value($firstname, $form['#node']->field_first_name[0]['value'], $form_state);
  $lastname['#parents'] = array("field_last_name", 0, 'value');
  form_set_value($lastname, $form['#node']->field_last_name[0]['value'], $form_state);
  $school_code['#parents'] = array("field_school_code", 0, 'value');
  form_set_value($school_code, $form['#node']->field_school_code[0]['value'], $form_state);
  $grade['#parents'] = array("field_grade", 'value');
  form_set_value($grade, $form['#node']->field_grade[0]['value'], $form_state);
  $nwsrs_id['#parents'] = array("field_nwsrs_id", 0, 'value');
  form_set_value($nwsrs_id, $form['#node']->field_nwsrs_id[0]['value'], $form_state);
  $qualifying_tournament['#parents'] = array("field_qualifying_tournament", 0, 'value');
  form_set_value($qualifying_tournament, $form['#node']->field_qualifying_tournament[0]['value'], $form_state);
  $qualifying_games['#parents'] = array("field_qualifying_games", 0, 'value');
  form_set_value($qualifying_games, $form['#node']->field_qualifying_games[0]['value'], $form_state);

  // Delete old Registration node
  $nid = $form['nid']['#value'];
  db_query('DELETE FROM {node} WHERE nid = %d', $nid);
  db_query('DELETE FROM {node_revisions} WHERE nid = %d', $nid);
}

Good luck out there....

Glenn

systematic’s picture

Line 408 of /modules/uc_node_checkout/uc_node_checkout.module seems to be the problem here.

The code checks to see whether the redirect option is enabled and whether or not the user has edit permissions for that content type. It does not differentiate between a new node or a node already created. It does not differentiate between a completed order or an order in progress.

As a starter I have edited the module so that ONLY newly created nodes (which do not yet have a node id) redirect to the cart.... I still have to figure how to differentiate between a node with order complete and one which is only part way through checkout ....

just add a condition to the line 408 : && !$form['nid']['#value'] so it becomes

 // Redirect non-administrators to the shopping cart after edits.
if (variable_get('uc_node_checkout_submit_redirect', TRUE) && !user_access('edit any '. $type .' content')  && !$form['nid']['#value']  ) {
  $form['#redirect'] = variable_get('uc_add_item_redirect', 'cart');
}

gutomec’s picture

Version: 6.x-2.0-beta3 » 5.x-1.0
Category: bug » support

Someone solve the problem of Ygg? I need to users pay to edit the node too, but version is 5.x.
Thanks.

fletch11’s picture

anyone figure this out yet - still getting duplicates if I go back at checkout and re-submit.

Thanks

aidanlis’s picture

Status: Active » Closed (won't fix)

I'm not supporting 5.x, if someone provides a patch please feel free to reopen the issue.