- Posts: 43
- Thank you received: 0
Adding a new filter to vendor orders
-- Joomla version -- : 3.5.1
Hi,
I want to setup a filter on the vendor order listing page that lets the vendor filter all of the orders by the city in the shipping address and was hoping for some guidance on how to do it.
I'm working on a layout override for HikaMarket - ordermarket / listing.php by taking the existing filter that's used for filtering the delivery method and changing it to filter the shipping address. The section of code I'm looking at is this:
obviously, it's not just a matter of swapping the word payment with the word city but if you can tell me what i need to do or what I'm looking for that would be a huge help.
Thanks.
Please Log in or Create an account to join the conversation.
Unfortunately, you cannot create a filter just with a view override.
The filter need to affect the SQL query which is made (to create the real filter).
So you have in one part in the view in order to create your selector (in "HTML") and in other part in a plugin in order to read the value selected by the vendor to alter the SQL query and create the filter.
There is nothing in HikaShop or in HikaMarket to display a list of cities.
HikaShop have a support of "zones" which are limited to countries and states, there is nothing which came deeper as cities.
And because the possible number of cities can be incredibly huge ; it is not possible to list them all in a dropdown.
For my point of view, you have to decide what cities you want to display ; what cities will be available for a filter.
Afterwards, the plugin need to read the value and add a new filter in the query (trigger: onBeforeOrderListing )
In the HikaMarket order listing ; you need to perform a link with the "address" table (with "order_billing_address_id" or "order_shipping_address_id") so you can then perform a filter on the "address_city" field.
Please note that creating a custom filter requires some PHP and SQL knowledge.
Trigger : OnBeforeOrderListing
You can read how that trigger in used in the plugin "hikashop/market" because HikaMarket is adding some filters in the HikaShop order listing.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.
Would there be any other way of been able to filter the orders by location? I did try putting some code into the order number format to insert the name of the town from the shipping address but that didn't work.
Please Log in or Create an account to join the conversation.
It could be possible but it would require important modification in the HikaMarket view.
For the moment the listing is loading some orders and, in a second time, it loads the associated addresses for the selected orders.
If you want to have some search fields ; you need to include the address directly in the first step but in that case you can't handle both address types (billing & shipping) due to the usage of the same table so with the same fields.
So, only one type can be used for the search and it will be something fixed..
The other possibility is to provide plugins in order to extend the search/filters ; so instead of modifying the HikaMarket core, plugin will just extend it and propose a specific feature when that plugin is published.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.
this is what I'm trying to do
the closest I've been able to get is
but that only exports the 1st letter of the cities name.
Please Log in or Create an account to join the conversation.
Please check the Joomla documentation about how to use the database in Joomla.
docs.joomla.org/Category:Database
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.
I understand that there is a SQL query that pairs the HikaShop_user and Hikashop_order tables embedded in the core files that loads all the data for the vendor listing page and I have no intention of changing any core files. I'm only making changes to the page overrides. With this in mind is there anything I can do to add in a filter function of some kind that uses data from a 3rd SQL table?
Please Log in or Create an account to join the conversation.
If the fields are available in the performed query, you will then be able to search into them.
Grid Sort - The ordering is in the "pageInfo", under " $pageInfo->filter->order->value ".
In HikaMarket, we set some restrictions on ordering values.
For the moment, the accepted ordering are :
Drop-down select - That inclusion can be made thanks to the $extrafilters.
Please take a look at the HikaShop/market plugin like I wrote in my message #241787.
It will give you sample code for the addition of an HTML filters and also sample to include extra table in the query.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.
I've never attempted to make a Joomla plugin before and it's going to be quite the learning curve to attempt it but I've never been one to back down from a challenge and this is something I do want to learn. I do know my way around SQL and converting it into JHTML is trickier than it looks but I am getting the hang of it and you have been a huge help with all of your knowledge and advice so I'll give it a shot. If it's ok with you I'd like it if would continue to give me some guidance while I try to build this plugin. If I do succeed I'd be more than happy for you to have a copy of what I've developed to use as part of HikaShop.
So my best option here is to work on a drop down filter plugin but because the query for the listing page is loaded in Hika's core files. This means my best option is to either create a new query in the plugin that joins the order and user table with the address table or find a way to merge the address table with the order and user table thats loaded from Hika's core.
Here is a copy of what I've done so far but how would I get this to work with HikaShop?
I assume that this is where $extrafilters comes into it? Do I need to place the whole function into a variable and then echo it on the listing page? But how do I get the plugin to become part of the HikaMarket vendor order listing page?
Do you have any examples or advice on what I need to do?
Please Log in or Create an account to join the conversation.
Please take a look at the HikaShop/market plugin like I wrote in my message #241787.
It will give you sample code for the addition of an HTML filters and also sample to include extra table in the query.
The parameter $extrafilters allow you to dynamically plug an Object which will be call for the display of the HTML in the view.
You can read how that trigger is used in the plugin "hikashop/market" because HikaMarket is adding some filters in the HikaShop order listing.
I'm thinking about creating some kind of sample plugin for the addition of extrafilter in HikaShop/HikaMarket.
But to be honest, it cannot be in a short period of time due to my current schedule and the work I'm doing on HikaShop 3 (because I want that we finish that major release).
Right now I can explain things about HikaMarket but giving you more details information would be the exact same thing that performing a custom plugin development. And in the other hand, you already have sample code in HikaMarket, like I told you several times.
I hope that you can understand my situation.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.