Drupal VIEWS Price Filter - drupal

I have a VIEWS page set up to display various products and would like to be able to filter them by price range. I've read that "Contextual Filters" is the right way to go about this but when I add a filter, the field (price) isn't listed.

Your filter doesn't need to be a contextual filter (those are used to fetch a parameter from e.g the url of your page). If you just need to filter your products by price just set a regular filter on the price field. If you want to define a range, set two filters : price > min and price < max. If you need to expose it to users, you have to set ajax on (advanced section), and you can use Better Exposed Filter to get a nice slider (with jQuery Slider).

Related

Showing count of content based on the select list values Drupal 7

I have a requirement in which I need to show some content along with its count based on values in a select list. I wanted to display the allocated,released and resigned resources of a particular department in a selected date range. Using views, date range and department fields are created as exposed filters.
Created a content type for creating resources. The Resources content type is having action as a select list with values allocated,released,resigned. Department is another select list and date field is also added.
Please help me with an answer if views module is not enough. Provide some other solutions also. I'm using Drupal 7.
I figured out how to show node count in views. In my view I’ve some exposed filters and passed my select list cck field as contextual filter. If no result available I made the view to display summary as row count. In the template file, I’m planning to do some calculations for showing the resources count in and out of the project. Please correct me if there is anything wrong in this approach.

Advanced Custom Fields - Filtering a Post Object Field by previously chosen Taxonomy

I have a custom post type called Event in which I want to add a location chosen from a large list of locations. To make this process easier I want to filter these locations by a category called locality.
To achieve this I have created a custom post type called Locations and a custom taxonomy called Locality. A field group holding two dropdowns one for Locality (Taxonomy) and another for Locations (Post Object) has been added to each event.
What I haven't managed to achieve is the filter of locations by the locality chosen.
I don't believe you can dynamically filter the choices of one custom field based on the current choice of another, and change that choice on the adminend. You can filter the choices that show up in your fields with a query modification that's very similar to WP_Query, and I'm pretty sure that can't be done on the fly.
I would almost cheat and instead of making posts with taxonomy assigned to them, include both the locality and the location in the post name itself.
So say, post [Museum of London] with taxonomy [London]
would become
[London][Museum of London]
[London][Hyde Park]... etc
or something similar. I'm presuming you only want to assign one location to any specific locality...
Then I'd create a relationship field and whenever I'm looking for Museum of London I'd type
London Muse...
It looks like this question is stale by now, but you would make your life easier if you added two custom fields to Event - location and locality. That way you don't have to join two tables and can easily use WP meta_query to filter posts.
What i understood is that you want that whenever you select the locality the location for it should be shown there and at last you can filter Events with locations.
=> To set location you assigned two drop-down for locality and location. You should use ajax. when i select any locality than the next drop-down has the options for the selected locality.
=> To add value in event post: you might have two options
i) you may add location as taxonomy and search using "tax query" to filter
ii) add location as parent of event and search "child of" in wp_query to filter
You have two options:
Program custom js to filter the locations field onchange of the localities field. This would not be so hard to do, because ACF sets the field id's for every field in their html. You can enqueue this js script in an admin hook (probably admin_enqueue_scripts, check this solution) and filter for the custom post type.
It can all be done in the ACF gui, but it's a bit of a trick, also because of the fact that the conditional logic for acf's taxonomy field is lacking. What you have to do is create as many Location fields in the Event acf fields as you have localities. Then set these locations to specific localities. Now comes the weird part. You would want to set the conditional logic to display if the locality is e.g. Russia, but it lacks a 'specific value' field. So you have to set two rules, one to set the 'greater than' and one to set the 'lesser than' for the id of the locality. . This will be a pain if you have a lot of localities, but it might be a good option if your localities list has no more than a few items. If you name the location fields all 'location' than you can just get the value with get_field('location'). I tested this and there is no conflict in naming all the location fields location. ACF has done a pretty decent job there, having unique names for these fields also to be able to name these fields as you whish.

how to limit view to just show each type one time?

I have a content type what is news, the news has a field type that is List (text) to keep different types of news. for example I have Health, Sport, Economic and etc.
So now I am going to create a block and have each of these type in that as a hyperlink.
I can do it and I created a new view block but each news_type may showing more than one time according to published content.
How to set the view (for block) to just show news_types and show them just one time?
You can achieve this by following the steps given below:
Enable aggregation under Advanced Accordion of the view
Add Nid field & set aggregation type as Count Distinct
Exclude Nid field from display
Add news type field & set Aggregation type as Group results together, in Group Column select Value option from dropdown
Remove Publishing Date from sort criteria
Please check attached screenshot for reference
You can check this question for more information, and maybe help you.

Add custom calculated shipping to the total on checkout in Drupal Commerce?

I want to add custom calculated shipping value (based on the origin of the shipment of the book) to the total amount of the order. I can now calculate the shipping value based on the order ID in my custom module....
I want to be able to add this value to the order total on checkout, is that possible?
I have tried shipment rules, but it is not satisfactory as it only allows me to add a value to the line items in the order and not to total. How can I hook to the checkout process and add this amount to the total? Maybe I can add it as custom line items on checkout?
Also, since it is a custom shipment method with customs shipment companies, do I need to use any of the shipment modules in the first place ( I neither use flat service or any of the commerce shipment modules) ?
Try API of respective commerce/ubercart module. They must offer some API which allows you to modify the check out page

Drupal 7 Views Expose Filter Price Range as Checkboxes

I am using Drupal 7 to build a product reviews site. The product reviews search page is built with Views 3 and Better Exposed Filters. I need an exposed filter for a price field that consists of price ranges as checkboxes. I have set up a grouped exposed filter for price with the proper ranges, made the filter allow multiple selections and then implemented hook_form_alter to set the filter to be themed with BEF checkboxes. The only problem now is the filter's where clause is searching for the ranges with an AND clause instead of an OR. So, I would like the user to select multiple price ranges and the results include products within either price range but instead the search is looking for product that are in both ranges, resulting in no products.
I have attempted to use hook_views_query_alter, but can not output so much as a dsm('test'). I think this may be because the view uses autosubmit.
Does anyone know how I can get this filter to work properly?
As the Advanced documentation of the Filter section says:
When using grouped filters with the option: 'Enable to allow users to select multiple items' checked, you probably may want to to place the filter in a separated group and define the operator of the group as 'OR'. This may be neccesary because in order to use multiple times the same filter, all options have to be applied using the OR operator, if not, probably you will get nothing listed since usually items in a group are mutually exclusive.
Therefore, you may want to create a new group (going to the 'reorder tab') and set the operator to OR. Then, just move the exposed filter inside that group.

Resources