I'm trying to assign an order to one of three user IDs at the beginning of a transaction, before any items are scanned and clear the user ID after the order is completed.

Using 1ID or 2ID as input after an item has been scanned and added to the order will set the user ID correctly, but I need this to be done before any items are added... Is this possible? It seems the order isn't created until an item is added, will I need to have the order creation function recognize adding a user ID as the trigger to create an order? So far I haven't gotten this to work.

Additionally, I would like to have the UID cleared from the next order once the first order is complete. So here's my POS workflow:
Cashier assigns a user ID to an order.
Cashier scans an item and completes the transaction.
UberPOS clears the user ID.
Cashier assigns a user ID to the next order.
...and so on.

Any advice would be greatly appreciated.
Thanks

Comments

coreywood’s picture

I've found a work around for this, by assigning a default customer to each new order.

One problem/annoyance I've run into doing it this way is that while you are able to assign a customer ID to an order before an item, UberPOS seems to treat the customer ID assignment as an item with zero price (even though the item list is empty) and tries to print a receipt... At least I assume it's somehow tied to the known issue of UberPOS printing a receipt when a zero price.

If anyone knows of a better way to accomplish this, or a way to fix the zero price printing issue, please let me know.

Here's where I set my default user in uberpos.module:

function uberpos_add_order() {
  global $user;
  $order = uc_order_new(4, 'pos_in_progress');
  uc_order_comment_save($order->order_id, $user->uid, t('Order on UberPOS.'), 'admin');

  return $order;
}

Here's where I have UberPOS create an order and assign it to a customer in uberpos.commands.inc

function uberpos_command_load_user(&$order, $item, $input, &$js) {
  $uid = drupal_substr($input, 0, drupal_strlen($input) - 2);
  $cmd = drupal_substr($input, drupal_strlen($input) - 2, 2);

  if ($cmd == 'ID') {
    // TODO: use query for speed
    $user = user_load(array('uid' => $uid));

    if ($user !== FALSE) {
      $order->uid = $user->uid;
	  $order = uc_order_new($user->uid, 'pos_in_progress');
	}
    else {
      uberpos_clear_message(t('Invalid user ID'));
    }
    return 'ID';
  }
}