Hello,
It seems that I am having some issues when either editing an existing order, or placing a new order when logged in as admin. First let me tell you about the products. The products are videos, and each video product has 4 different product/download options assigned to it, each with it's own SKU. So a product is set up like:
Video Title
- Format 1
- Format 2
- Format 3
- Format 4
A customer in the front end would have to select either Format 1, 2, 3 or 4 when adding the product to the cart by the means of radio buttons.
Now, that said here is issue number one - when editing an existing order as admin. Now, I am not sure if it is problem with my installation in specific, or a module conflict perhas, but...
1. Go to Administer/Store administration/Orders/View orders
2. Then click on an existing order to view, and then click on edit
3. I get "Loading product information... (If nothing happens, make sure you have Javascript enabled.)" (now I know it is enabled and I tried it on Windows IE, Firefox 3, Mac Firefox and Safari) and am getting the same thing.
4. When I click on "Submit Changes", all items previously in that order will be deleted.
5. When I go back to edit and then select "Add Product" and choose for example "Video Title1" and click "Select" and then "Format 3" as option, and click on "Add to Order" with quantity of 1, it shows that it is added below (and by the way if there were already items in that order then they would now show up too, that is if I didn't do step 4 prior 
6. Now if I go back down and select "Submit Changes" once again all of the items will be deleted!, even the one I just added.
7. If I don't click on "Submit Changes" then items will remain in order, however the wrong option will show! It seems to always add a product with the last option only in the list (so in this case even though I chose Format 3, the item will show up under View order with Fromat 4. Furthermore pricing is not applied accurately and sometimes the quantity gets changed.
Now, I am not sure if this has something to do with some module incompatibility, but I don't even know where to start to test this, or how to trouble shoot it. Truly strange.
If I let's say Add Product, and then click the "Submit Changes" button then I will see two log entries. One for Product added, and righ after that another with Products removed. So, something is not right.
Anyone?



Re: Problem when editing an order as admin or creating new order
Something on your site is causing a JS error on your order edit pages. You'll need to figure that out, but until then, don't submit any more order edit forms.
I recommend Firefox + Firebug for diagnosing JS problems.
Hello Ryan,
Hello Ryan,
Thanks for your reply. I did open up the Order / View page but.. guess what.. no page errors. There are no Javascript errors on that page, not when I try to add a product nor when I click the Update button at the bottom. The product just disappears. And if I don't click the update button at the bottom and just switch from edit back to view then the products do show up, but the wrong SKU (it seems to always show the 4 option even if it was not selected.) Furthermore on some added products the quantity dissappears (always the most recent added product has the quantity of 0 no matter what I enter before).
So.. no clue. I really don't feel like starting back up from scratch with a completely new setup.
Any other suggestions?
It seems that the Products: Add function when editing an order as admin, or creating a new order as admin is Ajax driven. I select a category and then it loads the products in that category in the right column. Then I select a product and click on "Select", then just that area loads and changes and it shows me the 4 different product options (with 4 radio buttons with the first option selected). Under that a quantity box with a 1 in it. Then below "Add to order" button. So, I leave option 1 selected and a 1 in the quantity box. And click "Add to order". Here is the source of that form:
<div class="order-pane abs-left"><div class="order-pane-title">Products: <input value="Add product" id="add-product-button" onclick="display_ubrowser('/', { 'div': '#products-selector', 'class': 'product-select-box', 'vid': '1', 'filter': 'product', 'search': 'true', 'nids': 'true', 'close': 'true', 'nodesg': 'product', 'nodepl': 'products', 'select': 'add_product_form();' });" type="button"> <input value="Add blank line" onclick="add_blank_line_button(80);" type="button"> <span id="product-div-throbber"></span></div><div class="product-select-box" id="products-selector"><div style="margin: 1em;"><strong>Video Title</strong><form action="/?q=admin/store/orders/80/add_product/18" accept-charset="UTF-8" method="post" id="uc-order-add-product-form">
<div><div class="form-item">
<label>Video Download Format: </label>
<div class="form-radios"><div class="form-item">
<label class="option"><input name="attributes[1]" value="1" checked="checked" class="form-radio" type="radio"> Windows Media® High - 640x480 - 12MB/min.</label>
</div>
<div class="form-item">
<label class="option"><input name="attributes[1]" value="2" class="form-radio" type="radio"> Windows Media® Low - 320x240 - 3MB/min.</label>
</div>
<div class="form-item">
<label class="option"><input name="attributes[1]" value="3" class="form-radio" type="radio"> QuickTime® High - 640x480 - 12MB/min.</label>
</div>
<div class="form-item">
<label class="option"><input name="attributes[1]" value="4" class="form-radio" type="radio"> QuickTime®/iPod® Low - 320x240 - 5MB/min.</label>
</div>
</div>
<div class="description">Please select a video download format</div>
</div>
<input name="nid" id="edit-nid" value="18" type="hidden">
<div class="form-item">
<label for="edit-add-qty">Qty: </label>
<input maxlength="5" name="add-qty" id="edit-add-qty" size="2" value="1" class="form-text" type="text">
</div>
<input name="op" id="edit-submit" value="Add to order" onclick="return add_product_to_order(80, 18);" class="form-submit" type="submit">
<input name="op" id="edit-cancel" value="Cancel" onclick="$('#add-product-button').click(); return false;" class="form-submit" type="submit">
<input name="form_token" id="edit-uc-order-add-product-form-form-token" value="9ecf979ad1575feaef455f80667fc197" type="hidden">
<input name="form_id" id="edit-uc-order-add-product-form" value="uc_order_add_product_form" type="hidden">
</div></form>
</div></div>
So after adding this product, which does work, I can add another, and another, etc. then at the very end I go to the bottom of the page and I will see "Submit Changes" button.
When I click it then the page reloads and guess what.. all products that I just added are no longer there.
Is it a Ubrowser problem? I have turned pretty much every module off. Sure don't know anymore what to do here.
Re: Hello Ryan,
I'm just not sure here... generally, the problem was that JS wasn't loading up the product pane at all. If it is showing up, then something else seems to be interfering with the form to prevent it from saving all your product changes. I doubt it would be uBrowser, but you can turn that off and try. (There's a fallback method of adding products to the order if uBrowser isn't enabled.)
Ok.. it's definitely a bug! Here is how to recreate
Ryan,
I tried it with virgin/unaltered Ubercart 5.14, 5.15, and 5.16. I compared it with a friends installation of 5.15 (and it was working - well, kind of - at least it wouldn't deleted an added item when one would click the "Submit changes" button. I thought I had to commit suicide after spending good 20 hours banging my head against the wall.
Finally I went through all settings and compared piece by piece my friend's settings, and my settings. Then I came to Store administration > Configuration > Table display settings: op_products_edit_table ----- /admin/store/settings/tables/op_products_edit_table
You can easily recreate my initial issue of added items, as well as pre-existing items being deleted upon "Submit changes" by only checking the following:
Remove - enable
Qty - enable
Name - enable
Model - disable (this is the key)
Price - enable
So, if Model is disabled it's not going to work. It will always deleted every single item that was added or was pre-existing in an order. That should definitely qualify as a bug, right?
Now that I found the bug of deleting items from my orders, I discovered another one. Please be sure to enable "Model" in op_products_edit_table. For that you must set up a product that has a product option (like I have "download format") and set up lets say 2 or more attributes under that option, and assign a different SKU to each. Then assign a different download file to each option value. In my case I have 4 different SKUs for "Video Product". The 1st sku and option attribute is set to default:
Option 1 - sku1/model1 - File 1
Option 2 - sku2/model2 - File 2
Option 3 - sku3/model3 - File 3
Option 4 - sku4/model4 - File 4
Now, when I go through the motions of "Add product" on the Order Edit screen, selecting "Video Product" from the catalog on the order edit screen, then click "Select".
Now I get presented with the options radio button list and select let's say Option 2, set quantity as 1 and click on "Add to order" button.
You will see that the product is now added to the order in the Product panel, but go and look into the "Model" text field. It actually added the sku4/model4 model, not the selected sku2/model2. When you click save and go back to the View Order tab you will see that actually Option 4 was added (and you will see the file download for Option 4 and the sku of Option 4) ---- even though we selected Option 2, remember?
So it seems that no matter what you select, only the very last option gets added.
I even tried selecting no option, and it still added the product with the Option4. So, I think this is definitely another big bug.
Please note that this behavior is the very same on my friend's system as well.
Is there a fix for that? Please advise.
Sincerely
Martin
Re: Ok.. it's definitely a bug! Here is how to recreate
Thanks so much for doing the research on this, Martin. I locked the columns that are mandatory for that table so no one else has this problem. Also, it looks like there's a solution in progress for your second problem in this issue, so I'm going to follow up with it there.
Also, I think this qualifies as a bug enough for you to get a badge out of it.
Thanks for the Badge - so shiny :)
Hey Ryan,
I wished I could have provided a solution to the problem on top of researching the issue. Anyway, thank you. I went over and am right now trying one of the patches that were published over there (the latest one). Will see what happens. Just glad that It wasn't me going crazy, but truly an issue in the code.
Have a great Thanksgiving!
Martin
Re: Thanks for the Badge - so shiny :)
Thanks, Martin. I just committed the fixes to our Bazaar repository, too, and they'll be included in the 1.7 release. Here's a quick diff that actually has line numbers:
=== modified file 'uc_order/uc_order.js'
--- uc_order/uc_order.js 2008-11-01 19:42:19 +0000
+++ uc_order/uc_order.js 2008-11-24 16:54:32 +0000
@@ -282,7 +282,14 @@
$('#uc-order-add-product-form :input').each(
function() {
if ($(this).attr('name').substr(0, 10) == 'attributes') {
- post_vars[$(this).attr('name')] = $(this).val();
+ if ($(this).attr('type') == 'radio') {
+ if (this.checked) {
+ // Only the checked radio button values should be sent
+ post_vars[$(this).attr('name')] = $(this).val();
+ }
+ } else {
+ post_vars[$(this).attr('name')] = $(this).val();
+ }
}
}
);
=== modified file 'uc_order/uc_order.module'
--- uc_order/uc_order.module 2008-10-27 21:28:01 +0000
+++ uc_order/uc_order.module 2008-11-24 16:54:32 +0000
@@ -1891,22 +1891,14 @@
function op_products_edit_table($op, $form) {
switch ($op) {
case 'fields':
- $fields[] = array('name' => 'remove', 'title' => t('Remove'), 'weight' => 0,
- 'enabled' => TRUE);
- $fields[] = array('name' => 'qty', 'title' => t('Qty'), 'weight' => 1,
- 'enabled' => TRUE);
- $fields[] = array('name' => 'title', 'title' => t('Name'), 'weight' => 2,
- 'enabled' => TRUE);
- $fields[] = array('name' => 'model', 'title' => t('Model'), 'weight' => 4,
- 'enabled' => TRUE);
- $fields[] = array('name' => 'weight', 'title' => t('Weight'), 'weight' => 5,
- 'enabled' => TRUE);
- $fields[] = array('name' => 'cost', 'title' => t('Cost'), 'weight' => 6,
- 'enabled' => TRUE);
- $fields[] = array('name' => 'price', 'title' => t('Price'), 'weight' => 7,
- 'enabled' => TRUE);
- $fields[] = array('name' => 'total', 'title' => t('Total'), 'weight' => 8,
- 'enabled' => FALSE);
+ $fields[] = array('name' => 'remove', 'title' => t('Remove'), 'weight' => 0, 'enabled' => TRUE, 'locked' => TRUE);
+ $fields[] = array('name' => 'qty', 'title' => t('Qty'), 'weight' => 1, 'enabled' => TRUE, 'locked' => TRUE);
+ $fields[] = array('name' => 'title', 'title' => t('Name'), 'weight' => 2, 'enabled' => TRUE, 'locked' => TRUE);
+ $fields[] = array('name' => 'model', 'title' => t('Model'), 'weight' => 4, 'enabled' => TRUE, 'locked' => TRUE);
+ $fields[] = array('name' => 'weight', 'title' => t('Weight'), 'weight' => 5, 'enabled' => TRUE);
+ $fields[] = array('name' => 'cost', 'title' => t('Cost'), 'weight' => 6, 'enabled' => TRUE);
+ $fields[] = array('name' => 'price', 'title' => t('Price'), 'weight' => 7, 'enabled' => TRUE, 'locked' => TRUE);
+ $fields[] = array('name' => 'total', 'title' => t('Total'), 'weight' => 8, 'enabled' => FALSE);
return $fields;
case 'data':
Re: Re: Thanks for the Badge - so shiny :)
Thank you! That worked. Have a great day.