Hi guys,
Just discovered this and am investigating. While the site is not live, uberpos is being used to track stock at the moment

drupal 6.16, latest dev build of uberpos.

Will update if I find out more.
Thanks
Jon

CommentFileSizeAuthor
#8 uberpos-752692-8.patch1.05 KBslip

Comments

jon_stewart’s picture

Update: Behaviour is same whether using an attributed product, or an attributed product from a subclass (we are discontinuing subclasses for various reasons)

slip’s picture

OK, I'll take a look when I get a chance. If anybody wants to take a shot at making a patch that would be great. I think I'll fix this one and the VAT bug and make an alpha release so we can have a true dev branch.

jon_stewart’s picture

By looking at a pending order, I can see that the base SKU has been used, not the SKU of the option

Two associated error reports:-
-------------1---------------------------------------------------------
Type php
Date Thursday, March 25, 2010 - 12:52
User jon
Location http://192.168.16.2/?q=admin/store/pos/ajax
Referrer http://192.168.16.2/admin/store/pos
Message in_array() [function.in-array]: Wrong datatype for second argument in /mnt.../uberpos/includes/uberpos.ca.inc on line 100.
Severity error
Hostname 192.168.16.56
Operations

------------end 1---------------------------------------------------

------------2--------------------------------------------------
Type php
Date Thursday, March 25, 2010 - 12:52
User jon
Location http://192.168.16.2/?q=admin/store/pos/ajax
Referrer http://192.168.16.2/admin/store/pos
Message array_keys() [function.array-keys]: The first argument should be an array in /mnt/...uberpos/includes/uberpos.ca.inc on line 100.
Severity error
Hostname 192.168.16.56
Operations

----------end 2--------------------------------

jon_stewart’s picture

Thanks, slip, I'm going to see if I can pick where it's going wrong, by way of trying to help.

jon_stewart’s picture

Problem is in this function, but as you can see, is because of a call to module_invoke_all

function uberpos_add_product($input, $order = NULL, $qty = 1, $attributes_extra = NULL) {
  /*
   * If the uc_attribute module is enabled, we need to check to see if the shop
   * owner has created any special skus in on the adjustments page to tie a sku
   * to specific attribute settings.
   */
  if (module_exists('uc_attribute')) {
    $result = db_query("SELECT nid, combination FROM {uc_product_adjustments} WHERE model = '%s'", $input);

    if ($item = db_fetch_object($result)) {
      $attributes = unserialize($item->combination);
      $nid = $item->nid;
    }
  }
  
  /*
   * No adjustment skus, so we just check to see if any products have a sku
   * matching the input.
   */
  if (!$nid) {
    $result = db_query("SELECT nid FROM {uc_products} WHERE model LIKE '%s'", $input);
    $nid =  db_result($result);
  }
  																																																						//watchdog('user','nid value query uc_products is:'.$nid);

  if ($nid) {
    $product = node_load($nid);

    if (isset($product) && node_access('view', $product)) {
      if (!$order) {
        $order = uberpos_add_order();
      }

      $product->qty = $qty;

      if ($qty > 1) {
        $product->title = $qty .'X '. $product->title;
      }

      $product->price = $product->sell_price;

     $product->model=$input;						// Correct assignment of sku

      if (isset($attributes)) {
        if (isset($attributes_extra)) {
          $product->data['attributes'] = array_merge($attributes, $attributes_extra);
        }
        else {
          $product->data['attributes'] = $attributes;
        }
      }
      else {
        if (isset($attributes_extra)) {
          $product->data['attributes'] = $attributes_extra;
        }
      }
						                                                     // at this point sku remains correct
												       watchdog('user','pre module invoke all product->model is:'.$product->model);
      module_invoke_all('cart_item', 'load', $product);
      												      // however, after module_invoke_all statement, sku defaults back to base sku
      												      watchdog('user','post module invoke all product->model is:'.$product->model);
      drupal_alter('order_product', $product, $order);
      uc_order_product_save($order->order_id, $product);

      if (variable_get('uc_order_logging', TRUE)) {
        uc_order_log_changes($order->order_id, array('add' => 'Added ('. $product->qty .') '. $product->title .' to order.'));
      }

      $order = uc_order_load($order->order_id);
      																																																						

      ca_pull_trigger('uberpos_item_added', $order, $product);
      

      return $order;
    }
  }

  return FALSE;
}

from the log:
user 03/25/2010 - 15:19 post module invoke all product->model is:nmLheaXX jon Note - 'XX' indicates the base sku
user 03/25/2010 - 15:19 pre module invoke all product->model is:nmLheatulp jon Note - This value is the correct sku

Hope this helps
I think this is about as far as I can take it, not being privy to the overall design!
Jon

jon_stewart’s picture

Title: Latest version not decrementing attributed products in database » Latest version defaulting attribute SKU's to base SKU: No database update or price adjustments
slip’s picture

Marked #620188: Attributes not working? as a duplicate.

slip’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB

Try this out... seems like they're changing the api around but I haven't had/don't have enough time to look into it.

jon_stewart’s picture

Status: Needs review » Fixed

Thanks for the patch.

Informally tested against
1. Attributed items as type product
2. Attributed items as a product subclass
3. Non attributed items
4. Random combinations of the above.

Both decrementation, and incrementation of database appears to be correctly functioning

(I'd not use the word 'appear' except my testing *was* informal!)

Many thanks for the quick fix, Silas

Jon

slip’s picture

Status: Fixed » Reviewed & tested by the community

Hmm, ok, tested on ubercart 2.1 and it worked there too. Not sure when it stopped working but that's good enough for me. If stock and everything else attribute-related works, I guess we're good to go.

slip’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for helping out with this Jon Stewart!

http://drupal.org/cvs?commit=347974

jon_stewart’s picture

Happy to help, and hey, that's my first credit for helping fix something. I've a big smile right now!

Todo:
1. Monetary contribution to Uberpos dev overdue :-(
2. Write some useful modules for the community, just like Uberpos.

Status: Fixed » Closed (fixed)

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

cjd400’s picture

I've applied this patch still seem to have a problem with it only showing the base price :( the patch didn't work to start with - but i've replaced the module with old version of the dev version - and it seems to have patched without errors but alas problem not resolved - anyone got any ideas?

chars

chris

cjd400’s picture

I've tried the new dev version doesn't seem to work in that either

left-click’s picture

Attribute skus do not work at all in the dev branch, mostly I think due to complications with multi-store support.

last call media’s picture

Sorry, that last post was me.

deggertsen’s picture

Status: Closed (fixed) » Active

If this isn't working in the dev version, shouldn't this be open? There are some great additions in the dev version that we need in UberPOS, but this issue negates all of that. We do not however, need multi-store support. So if that is the issue could you give an idea of what needs to be changed in order to get attributes working again?

Thanks.

deggertsen’s picture

I need to have this issue fixed. If somebody can do it at a price, name it and I'll let you know if I can pay you to do it. I would expect the fix to be no more than $300.

deggertsen’s picture

Status: Active » Fixed

I just updated to the most recent dev version and it appears to have fixed the problem. Awesome!

Status: Fixed » Closed (fixed)

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