I have a product kit that has 21 four digit SKUs in it. When I add that to an order on the admin/store/orders/XX/edit screen, it adds it as a single line item (even though I have the kit set to "as individual products"). If I try to add another product or submit changes, it says:

products cannot be longer than 128 characters but is currently 144 characters long.

and it highlights the SKU field which is all of the SKUs in the kit delimited by forward slashes. I would have expected that all of the individual parts would be added if I picked the kit, but that does not appear to be the case. Can the field be elongated or the parts added individually instead of all at once? We group parts into common kits but often times a few of the parts are removed from the order due to custom needs. Therefore we really need them to be broken into their individual parts when added to the order.

Comments

bancarddata’s picture

Interesting... seems if I clear out the SKU field and hit Submit Changes, it actually does break out all of the products in the kit and add them in as I would expect. However, it keeps the line item for the kit in there still too so the order total is effectively doubled. So it seems like maybe the SKU field just needs to allow for longer lengths, and we need to make it so that once all of the items from the kit are added to the order, the kit itself is either removed or set to zero dollars. I would be fine with either one - some people might like to know that it was a kit that was ordered so they might like the line to stay in there with a zero dollar amount. This all really only applies to kits that are set to "as individual products".

bancarddata’s picture

So, if I add a product kit with a lot of products to the order (i.e. click "Add product". choose a kit with a lot of products from the list, click "Select", then click "Add to order"), then refresh the page (without hitting "Submit changes"), the order shows the kit in exploded form with all the products listed individually and not as a single line-item kit. In other words, exactly how I would expect it to behave.

Is there some way to make this refresh happen automatically when I click "Add to order", or some other way to fix this issue? It seems like a timing problem (something fires before something else, that needs to be reversed).

longwave’s picture

Thanks for the detailed description. There is a bug somewhere in product kit handling, it just needs to be tracked down...

longwave’s picture

#1404636: Product kit attribute options not saved correctly from order edit form touched a similar issue which I think has the same cause:

@longwave: [...] the kit is shown unexploded immediately after adding it, but then if you refresh the page the exploded products show up correctly.
@wodenx: It's a bit more complicated to fix, though I think it's possible by moving uc_product_kit_uc_order_product_alter() functionality into hook_uc_order('presave', ...).

hanoii’s picture

Status: Active » Needs review
StatusFileSize
new3.73 KB

I was asked to look into this and I think I have come up with a fix, attached is a patched.

I added some special handling to product kits in the admin order side of things when adding products as well as changing one small bit on stock adjustment when the product was removed so that it properly logs the action (before it was being updated but without log).

I am also refreshing the order admin comments to show the stock updates (or any other log message that might have happened if the ajax module is used).

I wonder if this fixes some other issues in the queue. Anyway, tests as always appreciated.

hanoii’s picture

StatusFileSize
new4.92 KB

I found further issues related to admin side of product kits. I noticed that the code added for attributes to work, probably in the referenced issue above, was missing some data so other callbacks works.

The way it was done, the sub products were all being saved as 'product' instead of their specified product type. This caused a lot of issues, but the one that prompt me to debug this was that tax was being applied to all products but a lot of them were of a different non-taxed product class.

This is tricky and probably kind of badly ported from D6, so I added a fix that works at least for saving the product type properly. It only adds the nid to the subproducts form elements that is expected on the add_to_cart_data callback from the products module. As all of this was mainly specific to product_kit I believe the fix (although maybe not covering 100% of the issues) it's definitely an improvement over the current codebase.

I took the time to write an extended comment referencing to this issue and explaining what all of that is about.

Also I spotted one tiny issue in the previous patch about admin comments ajax refresh, which is sorted now as well.

hanoii’s picture

StatusFileSize
new4.92 KB

Re-rolled against latest dev, #6 applies anyway but to keep it up to date.

bancarddata’s picture

#7 patched perfectly against the latest dev - It appears to be working well for me - added a kit, was presented with options, made my selections, and it broke out nicely. We will have a chance to test it more thoroughly in the next couple of months. Thank you very much!

longwave’s picture

@hanoii: Can you split the admin comments Ajax issue out into a separate thread?

+  // Remove the field so we only refresh the admin comments item-list.
+  unset($form['admin_comment_field']);
+  $commands[] = ajax_command_replace('#order-pane-admin_comments .item-list', uc_order_pane_admin_comments('edit-theme', $form['#order'], $form, $form_state));
+

I don't know what this bug is and it doesn't look at all relevant to product kits.

hanoii’s picture

I could and is not really related to product kit issues, but is relatively simple that it would be almost a pity not to include it.

I actually spotted it because when adding the product kits I wasn't seeing the stock decrement messages and then I realized they were there, only not visible when added.

I will quickly explain it here and if you think is best to do it on a separate issue I'll copy it over:

Basically when you update things via ajax on the form, a bunch of elements get refreshed, product table, totals etc. Everything except the admin comments, so you miss comments created, say by stock decrementing. That bit of code only refresh the admin comment list, so it should hardly do any harm. The unsetting is only not keep styling properly as I am only want to refresh the item list, so I remove the field not to get it rendered.

hanoii’s picture

Title: Adding product kit to offline order creation page that has a lot of products produces error about field length » Adding product kit to admin created orders several issues
longwave’s picture

Yes let's have that in a separate issue, it's only a quick fix but it should be tracked separately.

hanoii’s picture

StatusFileSize
new4.4 KB

Ok, attached patched without the ajax comment thing.

hanoii’s picture

hanoii’s picture

again trying to push this one for review. Sorry about recent comments but as I upgraded ubercart I went over all of my patches manually so taking the time to promote them a bit more.