Adding a new filter to vendor orders

  • Posts: 43
  • Thank you received: 0
7 years 11 months ago #241750

-- HikaMarket version -- : 1.7.0
-- 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:

echo $this->paymentType->display('filter_payment', $this->pageInfo->filter->filter_payment, false);

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.

  • Posts: 26014
  • Thank you received: 4004
  • MODERATOR
7 years 10 months ago #241787

Hi,

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

function onBeforeOrderListing( $paramBase, &$extrafilters, &$pageInfo, &$filters, &$joins, &$searchMap ) {
}
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 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.

  • Posts: 43
  • Thank you received: 0
7 years 10 months ago #241852

Hmmm..... you're right that could be quite tricky and I don't think I've got the skill level to pull it off.

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.

  • Posts: 26014
  • Thank you received: 4004
  • MODERATOR
7 years 10 months ago #241891

Hi,

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.

  • Posts: 43
  • Thank you received: 0
7 years 10 months ago #242636

I've been working on the code and I've almost got it working but I'm having trouble calling up data from a SQL table that is used for a custom field. The field stores data in the address table but so far I can only call upon the tables joined in the $order variable. what would be the best way to call up data from the address table?

this is what I'm trying to do

$info = "SELECT address * WHERE order.order_shipping_address_id = address.address_id"

echo $info->address.address_city;

the closest I've been able to get is
echo $country['{address_city}'];

but that only exports the 1st letter of the cities name.

Please Log in or Create an account to join the conversation.

  • Posts: 26014
  • Thank you received: 4004
  • MODERATOR
7 years 10 months ago #242651

Hi,

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.

  • Posts: 43
  • Thank you received: 0
7 years 10 months ago #243132

Thanks for your help. I've been able to run a second SQL query that works in conjunction with the existing SQL query that uses the HikaShop_user and Hikashop_order tables. I now have the page looking the way I want but not working how I want. I still want to set up some kind of filter function using either the grid.sort, search box, or drop-down select.

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.

  • Posts: 26014
  • Thank you received: 4004
  • MODERATOR
7 years 10 months ago #243168

Hi,

function onBeforeOrderListing( $paramBase, &$extrafilters, &$pageInfo, &$filters, &$joins, &$searchMap )
* searchMap allows you to change the columns used during the search.
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 :
$orderingAccept = array('hkorder.','hkuser.');
Which mean that the order need to be on the HikaShop order table fields or in the HikaShop user table fields.

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.

  • Posts: 43
  • Thank you received: 0
7 years 10 months ago #243281

Well I'll be honest Jerome,

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?

$query->select($db->quoteName(array('address_id', 'address_shipping_route')));
$query->from($db->quoteName('#__hikashop_address'));
$query->where($db->quoteName('address_id') . ' = ' .$order->order_shipping_address_id);

echo "<select address_shipping_route=#__hikashop_address value=''>Shipping Route</option>";  
foreach ($dbo->query($sql) as $row){

echo "<option value=$row[1]>$row[address_shipping_route]</option>"; 

}

 echo "</select>";

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?

Last edit: 7 years 10 months ago by wernejo.

Please Log in or Create an account to join the conversation.

  • Posts: 26014
  • Thank you received: 4004
  • MODERATOR
7 years 10 months ago #243311

Hi,

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.

Moderators: Obsidev
Time to create page: 0.083 seconds
Powered by Kunena Forum