Hi,
I noticed that Payment Method is not enabled for use as a filter.
I ended up just putting this into uc_views.views.inc at line 276. This just achieves a simple string filter.
I added the 'filter' key to the array.
$data['uc_orders']['payment_method'] = array(
'title' => t('Order Payment Method'),
'help' => $order_schema['fields']['payment_method']['description'],
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
);
What would be cool though is to call _payment_method_list($action = NULL) and have all the payments available for a subclass of 'views_handler_filter_in_operator'.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | payment_method_filter.zip | 4.57 KB | psy |
Comments
Comment #1
psy commentedActually an even cooler solution is here.
Find attached 'views_handler_filter_payment_method.inc'. This adds a filter handler that simply gets an array of all payment methods that are registered in the uc_orders and provides them as a 'views_handler_filter_in_operator'
1. Place this file into the views folder
2. Update uc_views.views.inc near line 838 and add 'views_handler_filter_payment_method' => array('parent' => 'views_handler_filter_in_operator',), to the 'handlers' array in the function 'uc_views_views_handlers'
3. Add the filter key to payment_method field for the view. Near line 267 you need to add/change the filter key to
'filter' => array(
'handler' => 'views_handler_filter_payment_method',
),
Here some code for the file 'views_handler_filter_payment_method.inc'
Heres the code for the payment_method field
And here is the code for 'uc_views_views_handlers()'
Or download the attachment and place these files into the 'views' directory under 'uc_views' module directory
Comment #2
madsph commentedThank you for the suggestion. This sounds cool indeed.
I will take a look at it and get back to you when I have tested and committed.
Comment #3
psy commentedHi madsph,
I dont think that '_distinct_payment_methods()' is the most elegant solution. I just threw it together to get the job done. This is because the popup is populated using the machine name of the payment method both as the key (for the filter) and value (for the UI). However the payment method as displayed by the View field is that same machine name. It might be better to try and map the payment methods real name to machine name. This would be good for display of the field in the View as well, but whether its worth the trouble I am not sure.
All of this came about because our site uses multiple payment methods and we needed to filter those.
Your module is excellent BTW and has made our admin people very happy.
Comment #4
madsph commentedI have committed your patch to the dev branch.
I think you are right that it can be enhanced a little - but it works okay this way.
Thank you (again) for the great work!
Comment #5
psy commentedI just installed the dev version (3rd Nov).
Awesome work.
Im diving into the attributes as we speak.
This is a great module and i highly recommend it for any ubercart site!
Thank you very much for your efforts.
Comment #6
psy commentedSetting this to fixed.