I guess this isn't truly a support request for UC Views, but I'm still having the issue with #1541370: Move to next state moves orders two states

So I created a new action as part of uc_views_bulk_operations that moves orders to a specific state (rather than the next state). It works fine, but I usually prefer to put tweaks like this in their own module. Yet I can't get the callback function to fire. So let's say my tweaks module is TD Tweaks and the main file is td_tweaks.module. In that file, I create a new action and callback function that are the same ones I'm using in my hacked version of uc_views_bulk_operations, just renamed to td_tweaks_*

/**
 * Implementation of hook_node_operations(). (rather, hook_order_operations, which is based off the other)
 */
function td_tweaks_order_operations() {
  return array(
    'move_orders_to_processing' => array(
      'label' => t('Move to Processing'),
      'callback' => 'td_weaks_orders_move_orders_to_processing',
      'disabled' => TRUE,
    ),
  );
}

So far so good - I can add this action and it shows up on the form. But the callback function never fires.

function td_tweaks_orders_move_orders_to_processing($order_ids) {
  drupal_set_message("In callback for oder processing"); 
  dpm($order_ids, "Order IDs");
}

In other words, just trying to get the callback to fire, print out the order IDs (using devel and krumo) and setting a message. Once I get that to fire, I'll think about what I actually want it to do. But I can't seem to get the action to fire.

I know this is not truly a uc_views issue, but was hoping this was a good place to ask someone to point me in the right direction and figured anyone else trying to do something similar might look here. Thanks!

Comments

longwave’s picture

There is a typo in your 'callback' definition, td_weaks instead of td_tweaks? Otherwise I don't see why this wouldn't fire.

ergophobe’s picture

Wow! That is colossally stupid and embarrassing. No wonder my workaround worked... no typos!! Can't believe I didn't see that at the time. Much thanks Longwave for bothering to look at that after all this time.

For future reference, this is what it should look like in the working version.

/**
 * Implementation of hook_node_operations(). (rather, hook_order_operations, which is based off the other)
 */
function td_tweaks_order_operations() {
  return array(
    'advance_orders_to_processing' => array(
      'label' => t('Advance to Processing'),
      'callback' => 'td_tweaks_advance_orders_to_processing',
      'disabled' => TRUE,
    ),
  );
}

/**
 * Processes selected orders (moves them to next state in CA)
 */
function td_tweaks_advance_orders_to_processing($order_ids) { 
  foreach ($order_ids as $order_id) {
    $order = uc_order_load($order_id);
    uc_order_update_status($order_id, 'processing');
    drupal_set_message(t('Order #!order_id moved to processing', array('!order_id' => $order_id)));
  }
}
longwave’s picture

Status: Active » Fixed

Hehe, glad I could help even if it was a bit late!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.