I am using UberCart 6.x-2.3, and Node Checkout 6.x-2.0-beta4 and when the order's status gets updated to complete everything works as expected except I receive an error message that says 'Unable to send e-mail. Please contact the site administrator if the problem persists.' and I receive no email alerting me the node has been published. When I turn off the node publish module and do the same steps the error never comes up. Additionally when I edit the node related to the order I get the status message that the 'Order has been marked as completed.' with the same email error message which tells me that it is trying to send another email when the node is edited. That can't be right. Can someone please help? Thanks.

Comments

twistedindustries’s picture

Just wondering, is this module still being maintained? Is anyone else experiencing this issue?

avpaderno’s picture

Status: Active » Postponed (maintainer needs more info)

Did you verify that the e-mail is correctly set?

twistedindustries’s picture

It is set correctly.

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Active

I am changing back status.

deleuje’s picture

I was looking through the issue queue here trying to decide if I should use this.

I am using the uc_node_checkout 6.x-2.0-beta4 myself and I have been doing some tests tonight and the error message mentioned in the OP occurred to me as well.

What I am saying is it may not be an issue pertaining to this module but uc_node_checkout (or perhaps ubercart itself).

Anonymous’s picture

@deleuje; I am not sure I understood correctly; are you using this module too?

deleuje’s picture

Yeah, I was suggesting that the issue may be one of uc_node_checkout and not this module as I was getting similar errors earlier (though not using this module); but I see that he isn't getting errors when this module is disabled. So my speculation didn't have much merit to begin with.

avpaderno’s picture

Just wondering, is this module still being maintained?

The module is still maintained, but the maintenance level is minimum; this means that the code will be changed if somebody provides a patch, or points out what needs to be changed to fix an issue in the code.

avpaderno’s picture

Title: Send E-mail Issue » Issue sending emails

I am editing the issue title.

b0r7’s picture

Version: 6.x-1.0-rc3 » 6.x-1.0-rc4
Lilialex’s picture

I have the same error

uniquename’s picture

not sure, but the querys in uc_node_published_nodeapi return an empty result because they look for an order with the nid that is to be un/published, but uc_order_products contains the nid of the product... trying to get behind the logic...

uniquename’s picture

still not sure if i'm on the right way, but i can't find the exact meaning of uc_node_published_nodeapi...

I guess there is some confusion in the multiple ways the un/-publishing could happen e.g. order gets updated, node is edited or another module like node_expire is doing that.

I could get it to work for me by just adding the functionaity directly into uc_node_checkout by changing the function uc_node_checkout_order to handle the un-/publishing. it is more or less just a copy and paste of the two ops update and delete.

my function looks like that now.

function uc_node_checkout_order($op, &$arg1, $arg2) {
  switch ($op) {
    // Save node to order product associations upon order submission.
    case 'submit':
      // Loop through each product on the order.
      foreach ($arg1->products as $product) {
        // If it has a node checkout nid...
        if (!empty($product->data['node_checkout_nid'])) {
          // Save the association.
          uc_node_checkout_save_product_association($product->order_product_id, $product->data['node_checkout_nid']);
        }
      }
      break;

    // Add the node checkout teaser to products on order view screens.
    case 'load':
      // Skip the whole block of the teaser is not enabled.
      if (variable_get('uc_node_order_product_display', TRUE) && module_exists('uc_attribute')) {
        $attribute = variable_get('uc_node_order_product_attribute', 'ID');
        $option = variable_get('uc_node_order_product_option', '[nid] - [title]');

        for ($i = 0, $j = count($arg1->products); $i < $j; $i++) {
          if (isset($arg1->products[$i]->data['node_checkout_nid'])) {
            $node = node_load($arg1->products[$i]->data['node_checkout_nid']);

            if ($node) {
              $arg1->products[$i]->data['attributes'][token_replace($attribute, 'node', $node)] = token_replace($option, 'node', $node);
            }
          }
        }
      }
      break;
      
     // Un-/publish checkout nodes on order status 
    case 'update':
      if ($arg2 == 'completed') {
        foreach ($arg1->products as $item) {
          $node = node_load($item->data['node_checkout_nid']);
          $types = array_keys(uc_node_checkout_product_map());

          // Make sure we only affect uc_node_checkout related items.
          if (in_array($node->type, $types)) {
            // Publish the node.
            $node->status = 1;
            node_save($node);

            watchdog(
              'uc_node_published', 'Set @type %title to published.',
              array(
                '@type' => node_get_types('name', $node),
                '%title' => $node->title,
              )
            );
          }
        }
      }
      elseif (($arg2 != 'completed') && ($arg1->order_status == 'completed')) {
        foreach ($arg1->products as $item) {
          $node = node_load($item->data['node_checkout_nid']);
          $types = array_keys(uc_node_checkout_product_map());

          // Make sure we only affect uc_node_checkout related items.
          if (in_array($node->type, $types)) {
            // Unpublish the node.
            $node->status = 0;
            node_save($node);

            watchdog(
              'uc_node_published', 'Set @type %title to unpublished.',
              array(
                '@type' => node_get_types('name', $node),
                '%title' => $node->title
              )
            );
          }
        }
      }
      break;
      
    // Delete all nodes if the order is deleted to prevent orphaned nodes and clear cache  
    case 'delete':
      $search_wipe = function_exists('search_wipe');

      foreach($arg1->products as $item) {
        $node = node_load($item->data['node_checkout_nid']);
        $types = array_keys(uc_node_checkout_product_map());

        // Make sure we only affect uc_node_checkout related items.
        if (in_array($node->type, $types) && node_access('delete', $node)) {
          db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
          db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);

          // Call the node-specific callback.
          node_invoke($node, 'delete');
          node_invoke_nodeapi($node, 'delete');

          // Remove this node from the search index if needed.
          if ($search_wipe) {
            search_wipe($node->nid, 'node');
          }

          watchdog(
            'uc_node_published', '@type: deleted %title.',
            array(
              '@type' => $node->type,
              '%title' => $node->title,
            )
          );
        }
      }
      // Clear the page and block caches.
      cache_clear_all();
      break;
  }
}

i'll be happy about thoughts and ideas...

SchwebDesign’s picture

any updates on this? Same problem here is the main issue as well as comment 12, likely will try implementing comment 13. Also, this module just doesn't seem to work for me. I'm guessing because of what's mentioned in 12. (I do have node checkout content type workflow setting set to unpublished) When checking out or manually changing order status to completed, the node is not published.

thanks for this great module... a necessary addition to node checkout. here's to hoping i can get it working...

SchwebDesign’s picture

alright i implemented the code from comment 13 and commented out function uc_node_published_nodeapi and now the node associated withthe order is correctly published/unpublished. I know that's not the right way to solve this and I'd prefer to keep this purely modular, but it was the only way i could get this working for me for now (under a time crunch). Thanks uniquename for posting that code.

Perhaps it'd help to know i have the auto_expire module installed and enabled for the node checkout content type. Perhaps thats conflicting?

ashhishhh’s picture

Module is working for me except the unwanted messages

  • Order has been marked as completed.
  • Unable to send e-mail. Please contact the site administrator if the problem persists.

on line number 67 and 91 variable $node->previous_status is NULL and never could be set to 1.
I change the load behavior

function uc_node_published_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  static  $previous_status = '';
  // Get the node types uc_node_checkout links.
  $types = array_keys(uc_node_checkout_product_map());

  if (in_array($node->type, $types)) {
    switch ($op) {
      case 'load':
        $previous_status = $node->status;
        break;
      case 'update':
        $node->previous_status = $previous_status;
        // Unpublishing...................................
............................

tanjerine’s picture

I don't know if this is specific to my installation of ubercart (6.x-2.4) with Node Publish (6.x-1.0-rc4), because I sort of inherited the half-built site from someone else, but this was how I fixed the "Unable to send email" message --

Basically for all the lines that had:

db_query(
  "SELECT * FROM  {uc_order_products} WHERE nid = %d", $node->nid
)

I changed it to:

db_query(
  "SELECT * FROM uc_order_products up
  JOIN  uc_node_checkout_order_products uc ON up.order_product_id = uc.order_product_id
  WHERE uc.nid = %d", $node->nid
)

Hope this helps.

peter.bod’s picture

I have the same problem as in #16
How can I remove the messages? "Order has been marked as completed."
Additionally, the word "Order" is a link to the "admin/store/orders/" which is not accessible by this user.

Matthi2’s picture

Hello,

i have had the same problem:

my solution is hacky, but it works ;-)

The user receives no email now.

Just look for

uc_node_published_update_notify($order);

and comment it out.

millionaire’s picture

Thanks @Matthi2 and @uniquename - both solved my problems
I also removed the a href on: 'Order @order has been marked as completed.',
That lost the dodgy link to the orders section.

The module has caused a couple of issues with "Job Posting" - oh well, one step forward, two steps back ;)

avpaderno’s picture

Version: 6.x-1.0-rc4 » 6.x-1.x-dev
Issue summary: View changes
Status: Active » Closed (outdated)

I am closing this issue, since Drupal 6 is not supported anymore.