Hi there,

still a newbie and Danish, so my english is not that good.

But i try to make a site that sells one product: Acces to get a node on the site.

We're talking DP 7, UC 3 with node checkout. All nearly working!

When a customer add a node, my product is adding to the cart and the customers node is created. BUT if the customer is not chekout and pay - the node is still created and visble on my site.

So, the Node checkout modul do not delete the created node when there is not payed for it and if the customer delete the associated product in the cart, the created node is not deleted either!

Is there any body there can give a hand here! - I have used a lot of hour on this issue. is it the settings or the module?

thanks.

Comments

LarsKaae’s picture

Component: Miscellaneous » Code
anthonyjhall’s picture

Currently this module lacks any documentation on displaying nodes only when they are paid for - it's main feature.

However, this does work in D7:

http://drupal.org/node/376384#comment-5480138

For this approach you set the default for the node type to be created by visitors to "upublished" and the Rule publishes it once payment is made.

There's an alternate approach in this old guide which adds an integer field for "status" which is then updated on checkout. You would need to set up any views displaying your customer created nodes to only display items with this status.

Don't know if this PHP snippet works in D7, the screenshots for the rules setup are missing so I used the approach above which seems OK.

http://drupaleasy.com/blogs/ultimike/2009/03/event-registration-ubercart

santosh.sarkar’s picture

I am also facing same problem...
the node is created after adding a product to cart.
but not deleted when clear the cart....

G Gavitt’s picture

I had the same issue with nodes not being deleted when an node check out item is removed from the cart.

This is related to hook_uc_cart_item being removed from the latest versions of ubercart.

See this issue for some related fixes. http://drupal.org/node/1696914

That patch will not fix the delete node issue though. However it should add the data you need to do it in a submit callback.

I did not patch the original module any further but I do have a work around once the patch from http://drupal.org/node/1696914 has been installed.

In a custom module I used a hook_form_alter and added a extra submit callback for form id 'uc_cart_view_form';

EG.

  $form['#submit'][] = 'YOUR_MODULE_NAME_remove_callback';

then in your call back function

function YOUR_MODULE_NAME_remove_callback ($form, &$form_state){

  if (substr($form_state['triggering_element']['#name'], 0, 7) == 'remove-') {
   
   $remove_num = substr($form_state['triggering_element']['#name'], 7);
   $cart_item_id  = $form_state['values']['items'][$remove_num]['cart_item_id'];
   $item_pre = $form_state['build_info']['args'][0][$cart_item_id];
	
    if (variable_get('uc_node_checkout_delete_nodes', TRUE)) {
      if (isset($item_pre->data['node_checkout_nid'])) {
         node_delete($item_pre->data['node_checkout_nid']);
       }
     }  
   }  
} 

That is deleting the node for me when the user clicks on the remove button. I have tested it a bit and so far so good but YMMV.

I also wanted to fix the remove message pointing back to a non-existent node.

Replace

   if (!empty($form_state['post'])) {
      foreach (array_keys($form_state['post']) as $key) {
        if (substr($key, 0, 7) === 'remove-') {
          $deleted_items[] = (int) substr($key, 7);
        }
      }
    }

with

     if (!empty($form_state['input'])) {
	foreach (array_keys($form_state['input']) as $key) {
          if (substr($key, 0, 7) === 'remove-') {        		   
            $deleted_items[] =$form_state['input']['items'][(int) substr($key, 7)]['cart_item_id'];
        }
      }
    }

in uc_node_checkout.module.

That should display a message that just shows the name of the parent node checkout product without an edit link on item removal.