If the Shipping Quotes module is enabled, but Payment is not, there is a JavaScript error on the Order Edit page. The global line item variables aren't defined, but assumed to be by uc_quote.js.

Comments

Island Usurper’s picture

Title: JS error from hidden dependencies » Line items overhaul
Category: bug » task
Priority: Normal » Critical

Might as well get to the real problem. (For one thing, it was uc_taxes.js, not uc_quote.)

Line items are a basic property of an order, so they shouldn't be defined and controlled by the payment module. The only thing they have to do with payments is contributing to the order total. So, I propose that code dealing with line items be moved to uc_order or to their own module dependent on uc_order. This would remove the hidden JS dependence that uc_taxes has on uc_payment, as well as allowing websites to take orders without immediate payment. Even those customers should have the opportunity to see the line item breakdown of their order.

rszrama’s picture

Status: Active » Postponed

Agreed. We keep tossing this one around, and line items really need to be bigger, badder, and easier to use. I'm marking this postponed, but I would LOVE to revisit it in 3.x development.

tr’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Postponed » Active
Island Usurper’s picture

Title: Line items overhaul » Checkout panes and line items overhaul
Assigned: Unassigned » Island Usurper
Status: Active » Needs review
StatusFileSize
new89.46 KB

I like being able to completely take over my own issues. :)

One of my goals for 3.x was to redo the JavaScript that was being used to get the shipping quotes on the checkout page. So I started implementing #ajax on the quote_button, and one thing lead to another. Now the order totals preview also uses #ajax, and it no longer depends on all of the code in uc_taxes.js, uc_quote.js, or the line item functions in uc_payment.js.

There's still more to do, such as making sure the shipping quotes still show up on the cart pane and the order page. A lot more of the JavaScript can probably be taken out as well, now that it isn't being loaded.

The diff of the changes is included in the merge file, so it's possible to patch off of those lines.

rszrama’s picture

Epic.

Island Usurper’s picture

I've got the order page mostly working now. The product pane now uses AJAX to add and remove products. Editing products now doesn't use JavaScript at all since that table is generated by the form automatically. I'm still trying to figure out how to get the line items to update whenever the products are changed.

I want to get a few more things done before I commit this to CVS, but I also don't want to post the ever-increasing patch file every time I make a change. So I made a new Bazaar branch that you can get with bzr branch bzr://bazaar.ubercart.org/drupal7-uc3/ajax ubercart. Run that command in your modules folder to get a fresh copy of the code. If you already have an ubercart folder, but it's not from a Bazaar branch, then the easiest thing is to move it out of the way.

If you already have a Bazaar branch, you can use bzr pull or bzr merge with the URL to get the changes.

I'll keep posting updates as I hit milestones, but I still I want to see your reviews.

Island Usurper’s picture

Now the quote cart pane uses AJAX. But it looks funny while the throbber is spinning. I've noticed that all over the place, so I wonder why the styling is messing up.

rszrama’s picture

fwiw, I've noticed that, too. The throbber screws up floats or something, so I wouldn't worry about it in your code. It's something in Drupal core.

Island Usurper’s picture

Title: Checkout panes and line items overhaul » Checkout panes, order panes, and line items overhaul

At this point, the line items are actually changed whenever a product is added or removed, but that's because I'm not using AJAX for that final step any more. This was especially critical for removing products because the browser will look like it took out the last product on the list even though it did not! If the page is refreshed before the whole form is saved, the correct values will show up in the fields again. This is the same problem with the tax line item amount. Ubercart is calculating the correct amount, but the browser sees that there was a value there, and preserves it for you, to keep things user-friendly.

The only way I know around that is to rebuild the whole form again, so that's what we're doing.

Island Usurper’s picture

Alright, I've spent some time polishing this thing, and I believe I've taken care of everything that needs to be done. Code that no longer runs has been ripped out, menu paths and callbacks removed, even a database table field was dropped.

I'm getting pretty close to committing this, because I want to make sure the Rules integration will have a stable platform to be built upon. So, if there are any glaring errors, this is the time to speak up. :)

Island Usurper’s picture

StatusFileSize
new241.53 KB

Bah! Totally forgot to post the latest patch.

Island Usurper’s picture

Status: Needs review » Fixed

BOOM!

The sound you have just heard was that of a patch landing. Now, I can work on Rules integration, fix the address forms, and maybe make orders fieldable. Won't that be awesome?

Status: Fixed » Closed (fixed)

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