Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When you create a new order from admin/store/orders/create is you fill the order and before hitting "Submit changes" you apply a shipping quote to that order all order data is not saved.
This happens because "Get shipping quote" form calls submit form uc_quote_apply_quote_to_order($form, &$form_state) but never pass back the $form_state to uc_order_edit_form_submit($form, $form_state).
A simple workaround is to put a line like this:
uc_order_edit_form_submit($form, $form_state);
in uc_quote_apply_quote_to_order($form, &$form_state) patch will follow.
Comments
Comment #1
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #2
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #3
SilviuChingaru CreditAttribution: SilviuChingaru commentedNot working anymore with the patch from #1410302: Notice: Undefined index: method and rate in uc_shipping_shipment_edit(); #3
Comment #4
SilviuChingaru CreditAttribution: SilviuChingaru commentedStill present in RC4...
Comment #5
TR CreditAttribution: TR commentedAgain, an open issue is by definition not fixed yet. Please read http://drupal.org/node/156119 if you're unsure what the issue statuses mean. If you want to help get this fixed, then submit a working patch for review.
Comment #6
SilviuChingaru CreditAttribution: SilviuChingaru commentedAs you can see in all my posts I'm trying to fix every bug that I can so do not understand the attitude. I thought maybe a "happy accident" fixed the bug. ;-) :-)
Comment #7
SilviuChingaru CreditAttribution: SilviuChingaru commentedThis should be fixed when #1410302: Notice: Undefined index: method and rate in uc_shipping_shipment_edit(); is fixed. If the order will not reload the data will be "saved".
Comment #8
longwaveWill be fixed in #1410302: Notice: Undefined index: method and rate in uc_shipping_shipment_edit();
Comment #9
longwaveReopening, as this is technically a separate problem; the other issue is a display error which could occur when there is genuinely no valid quote attached to the order.
Comment #10
SilviuChingaru CreditAttribution: SilviuChingaru commented@longwave
Ok, so my patch is better putted here. I don't know from where $form['line-items'] are generated because my patch, the one attached, is working both ways:
- it modifies order form id='order-line-items' but only the Total. Also if i put an empty ajax_command_replace('#order-line-items', '') the div content is erased.
- the $form var (dpm($form)) is getting the new quote values but the textfield values and amount are not changing so if you click Submit changes the shipping line item is saved to database with the label and ammount of first loaded shipping method. The last selected shipping method applied in shipping form is also saved to order.
So, I'm thinking that there is a little problem with the ajax callback or line_items are cached somewhere?
Please help, I worked on this patch for one day and still no solution... At least a clue where to look for docs or something.
Comment #11
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #12
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #13
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #14
end user CreditAttribution: end user commented> "happy accident" Bob Ross ftw!
Comment #15
SilviuChingaru CreditAttribution: SilviuChingaru commentedStill no progress on this... :(
Please help.
Comment #16
SilviuChingaru CreditAttribution: SilviuChingaru commentedThis is the right title for this topic.
Comment #17
SilviuChingaru CreditAttribution: SilviuChingaru commentedI wander is just me bothered by this bug?!
Comment #18
SilviuChingaru CreditAttribution: SilviuChingaru commentedI'm willing to donate to anyone who fix this issue. Just tell me how much and if we agree I'll make the donation when patch is ready. I am desperate to solve this issue.
Comment #19
SilviuChingaru CreditAttribution: SilviuChingaru commentedI managed so far to make both shipping buttons use ajax (no order reload and lose unsaved data). Even the shipping method is saved ok to the order BUT the line item 'shipping' is not changed via ajax and if we click save the right shipping method is selected but it gets the name of first form build shipping method.
What I did so far:
The quote button should be called via ajax too so we need to add the following to original function:
ajax callback looks like this:
We need to instruct drupal_process_form to rebuild the form not submit it so we add the following:
Is working so far but order line items don't get updated via ajax. Why? Where could be the problem?
Comment #20
SilviuChingaru CreditAttribution: SilviuChingaru commentedNevermind... fixed.
Comment #21
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #22
SilviuChingaru CreditAttribution: SilviuChingaru commentedPatch...
Comment #23
SilviuChingaru CreditAttribution: SilviuChingaru commentedStill has a bug:
If admin change qty of a product and click GET SHIPING QUOTES button without saving the order first, the weight shipping is not re-calculated. The problem I think should be fixed by adding the submit form function in #submit array of GET SHIPPING QUOTE. I'll try if it works and post a patch.
Comment #24
SilviuChingaru CreditAttribution: SilviuChingaru commentedI think better will be to apply shipping quotes on $form_state order products and qty... I'll try this in order to close this issue.
Comment #25
SilviuChingaru CreditAttribution: SilviuChingaru commentedAnd the final patch in order to close this issue...
If user edit an order from admin page, he changes quantities of one or more product and then click on "Get shipping quotes" button without clicking "Save changes" button, the shipping quotes are calculated based on new changes. The order is not saved when he clicks "Get shipping quotes" but when he click "Apply to order", the order is saved and the shipping line item is updated as it should.
Should we save the order on "Apply to order" or just update shipping line item and save the order only when user clicks "Submit changes"???? Normally, I think, all changes to the order should be made on "Submit changes" but this wasn't the original behavior of "Apply to order" button. Waiting for suggestions...
Comment #26
SilviuChingaru CreditAttribution: SilviuChingaru commentedBump... The last patch is ready for commit. I'm using it on a production site and no bug with it.
Comment #27
SilviuChingaru CreditAttribution: SilviuChingaru commentedI don't understand why this patch didn't make it to 3.1 release?! Is not so important the admin order part of ubercart or what?
Comment #28
SilviuChingaru CreditAttribution: SilviuChingaru commentedI've tested this patch for more than 5 months now and I think is ready for commit.
Comment #29
longwaveI simplified the patch a little and changed some comments, but otherwise this looks pretty good - thanks for working on it. And sorry for taking so long to get around to reviewing it, I wanted to try and clean up some of the surrounding code at the same time, but I think that's for another issue; the order edit form, line items and shipping quotes code are some of the ugliest parts of Ubercart, and this touches all of those.
Comment #30
longwaveCommitted #29
Comment #32
SilviuChingaru CreditAttribution: SilviuChingaru commentedThank you... it was about time... :-)