I am using ubercart-rc3 with uc_vat, views_bonus and uc_views and working on providing a good product report in CSV for the customer. I will somehow try to collaborate with uc_views in order to expose some more that from what's currently exposed but I found the one exposed by ubercart a bit limited. While this might sound a bit custom, it's definitely more flexible, and flexibility is always good.

What I am doing is extending the price (and weight as a bonus) handlers to be a subclass of a numeric handler instead of a base handler. I also defined the data for prices and weight as float and give a nice format option to the handler (both price and weight) so you can choose to use Ubercart defaults (uc_price() and uc_weight()) or use the standard numeric render() from the stored value on the db.

This is important because if somehow I want to get the raw value from the db (without any rounding or formatting) there was no way to do that. I know I can somehow plug into the new price handler/alter logic that's been worked out but this sounded as a lot more views-like approach.

I worked the patch with rc3, but checked out the DRUPAL6--2 branch from CVS and rework it there and also test it out. Attach is patch against current CVS.

I know this is hardly a Release Blocker issue but it might be nice to have this on the final 2.0. I think a lot of uc_vat/uc_views users will appreciate it.

Comments

hanoii’s picture

Status: Active » Needs review
hanoii’s picture

StatusFileSize
new6.48 KB

Re-read the patch and changed a couple of words in some comment lines.

Island Usurper’s picture

Status: Needs review » Fixed
StatusFileSize
new6.7 KB

Thanks, hanoii. There's a lot of stuff that's available in Views that I don't know how to take advantage of everything. Committed the patch with a couple of stylistic, whitespace changes.

hanoii’s picture

I am glad to help. I'd like to point you to a related issue in which I'd like to hear your thoughts.

#591126: Move Views support to uc_views?

Status: Fixed » Closed (fixed)

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

hanoii’s picture

Title: uc_product views support enhancements » uc_product price views bugfix and one small enhancement
Version: 6.x-2.x-dev » 6.x-2.0
Category: feature » bug
Status: Closed (fixed) » Needs review
StatusFileSize
new2.01 KB

I am bringing this issue back to life because I found a bug on the code. Not sure how, but there's a bit of code that went into the product's price handler that was causing the actual value of the field not to be included on the views result. On normal use of this handler (with uc_price() this wasn't a problem because the price was really taken from the loaded product rather than from the view, but when used with numeric, as I am currently using, the value was not there at all because of query() being overridden.

That bit of code was not added by my patch on this issue, but got there some other way.

Attach is a fix for that and also one more enhancement to the views price handler. When using the uc_price formatting option you now have the different revisions to choose from (altered, original, formatted, formatted-original, themed and themed-original). It's a nice and easy add-on, but the bugfix is important.

Thanks,
a.=

Docc’s picture

I can confirm the bug. Aswell that the #6 patch fixes the issue

Island Usurper’s picture

Status: Needs review » Fixed

Committed. Thanks, hanoii.

I think I must have put the query() method in there because I was going off of the add_to_cart handler instead of digging down to see what I was actually overriding.

Status: Fixed » Closed (fixed)

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

hanoii’s picture

Version: 6.x-2.0 » 6.x-2.2

Just noting that this is a valid bug for version 2.2, as I thought it was fixed on that version. The commit happened after the release.